Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

narrow down typing for hook and step functions #2040

Closed
davidjgoss opened this issue May 15, 2022 · 1 comment
Closed

narrow down typing for hook and step functions #2040

davidjgoss opened this issue May 15, 2022 · 1 comment
Assignees
Labels
⚡ enhancement Request for new functionality

Comments

@davidjgoss
Copy link
Contributor

davidjgoss commented May 15, 2022

🤔 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'
  • (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.

📚 Any additional context?

Originally discussed in #2038 (comment)

@davidjgoss davidjgoss added 💔 breaking change This will require a major release ⚡ enhancement Request for new functionality labels May 15, 2022
@davidjgoss davidjgoss added this to the 9.0.0 milestone May 15, 2022
@davidjgoss davidjgoss self-assigned this Feb 16, 2023
@davidjgoss davidjgoss modified the milestones: 9.0.0, 10.0.0 Feb 16, 2023
@davidjgoss davidjgoss removed this from the 10.0.0 milestone Oct 7, 2023
@davidjgoss davidjgoss removed the 💔 breaking change This will require a major release label Oct 7, 2023
@davidjgoss
Copy link
Contributor Author

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.

@davidjgoss davidjgoss closed this as not planned Won't fix, can't repro, duplicate, stale Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

1 participant