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

Fix: correct Mocha overloads order #59075

Closed
wants to merge 1 commit into from
Closed

Fix: correct Mocha overloads order #59075

wants to merge 1 commit into from

Conversation

JoshuaKGoldberg
Copy link
Collaborator

@JoshuaKGoldberg JoshuaKGoldberg commented Mar 2, 2022

Please fill in this template.

Select one of these and delete the others:

If changing an existing definition:

Corrects function overloads for it and the like in Mocha so that the more specific async parameters come first per microsoft/TypeScript#48077 (comment) (thanks @MartinJohns!).

I tried switching to unions but hit test errors about this no longer being defined: https://github.com/DefinitelyTyped/DefinitelyTyped/runs/5394917747?check_suite_focus=true

Error: /home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ember-mocha/ember-mocha-tests.ts:79:9
ERROR: 79:9    expect  TypeScript@4.7 compile error: 
'this' implicitly has type 'any' because it does not have a type annotation.
...

Throwing this PR up as a draft while there are test failures as reference for microsoft/TypeScript#48088.

@typescript-bot typescript-bot added this to Needs Author Action in New Pull Request Status Board Mar 2, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title Fix: correct Mocha overloads by switching to unions Fix: correct Mocha overloads order Mar 2, 2022
* - _Only available when invoked via the mocha CLI._
*/
(fn: AsyncFunc): void;
(fn: Func | AsyncFunc): void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we would use a rest parameter with a discriminated union type instead of function overrides as a workaround?

For example:

type HookFunction = (...args: [Func|AsyncFunc] | [string, (Func|AsyncFunc)?]) => void;

@JoshuaKGoldberg
Copy link
Collaborator Author

Closing as this is no longer relevant to me 🙂 . Feel free to pick back up, anybody!

@typescript-bot typescript-bot removed this from Needs Author Action in New Pull Request Status Board May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants