You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TypeScript typings for the functions users pass in to hooks and steps should have the return value appropriately typed so it's clear what you can and can't influence from the function.
Currently the return value for all of them is typed as
any | Promise<any>
We should make these more specific.
We should also check the signature of the callback function for that style of step, for the same reason.
✨ What's your proposed solution?
Here's what I think each function should be able to return (in each case it could be a plain value of this type, or a promise that resolves to one).
BeforeAll, AfterAll - void
Before, BeforeStep - void | 'skipped'
(actual steps) - void | 'skipped' | 'pending'
AfterStep, After - void
This might be a breaking change, although we call allow a fallback of any at the end of the type union so it's permissive but still surfaces hints as users type - that would probably be the ideal.
I took a quick run at this today and found it difficult given how spread out our code and types for user code is, with SupportCodeLibraryBuilder etc. It might be one to return to once we've had a chance to simplify that area a bit.
🤔 What's the problem you're trying to solve?
The TypeScript typings for the functions users pass in to hooks and steps should have the return value appropriately typed so it's clear what you can and can't influence from the function.
Currently the return value for all of them is typed as
any | Promise<any>
We should make these more specific.
We should also check the signature of the callback function for that style of step, for the same reason.
✨ What's your proposed solution?
Here's what I think each function should be able to return (in each case it could be a plain value of this type, or a promise that resolves to one).
BeforeAll
,AfterAll
-void
Before
,BeforeStep
-void | 'skipped'
void | 'skipped' | 'pending'
AfterStep
,After
-void
This might be a breaking change, although we call allow a fallback of
any
at the end of the type union so it's permissive but still surfaces hints as users type - that would probably be the ideal.📚 Any additional context?
Originally discussed in #2038 (comment)
The text was updated successfully, but these errors were encountered: