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 #4260 : Allow trailing arguments that accept void to be omitted #27522

Merged

Conversation

jack-williams
Copy link
Collaborator

Fixes #4260

@RyanCavanaugh
Copy link
Member

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 3, 2018

Heya @RyanCavanaugh, I've started to run the extended test suite on this PR at 2b44a1b. You can monitor the build here. It should now contribute to this PR's status checks.

@RyanCavanaugh
Copy link
Member

@jack-williams FYI I expect the test run from the bot to fail so don't get worried if it comes back red

@jack-williams
Copy link
Collaborator Author

No worries! Thanks for picking it up

src/compiler/checker.ts Outdated Show resolved Hide resolved
@jack-williams jack-williams force-pushed the trailing-void-args-are-optional branch from 2b44a1b to eae8ef1 Compare October 3, 2018 18:09
@jack-williams jack-williams force-pushed the trailing-void-args-are-optional branch from eae8ef1 to 342fda9 Compare October 3, 2018 18:35
@jack-williams
Copy link
Collaborator Author

This doesn't fix something like:

declare function foo<T = void>(x: T);
foo(); // T = void, expected 1 arg, 0 given

which I actually think is one of the more useful scenarios. I disabled this behavior because otherwise it means you have to do arity checking again after instantiation which messes with overloading. I'm wondering if we could put in a special case for 1 signature? If it's seems useful enough that is.

@RyanCavanaugh
Copy link
Member

@jack-williams I don't find that example super compelling given that it potentially requires multiple iterations of reasoning, e.g.

type MaybeVoid = T extends void ? void : object;
declare function foo<T = void>(x: T, y: MaybeVoid<T>);
foo();

@RyanCavanaugh RyanCavanaugh merged commit b64d08a into microsoft:master Oct 19, 2018
@jack-williams
Copy link
Collaborator Author

@RyanCavanaugh Ye I’m inclined to agree. Thanks for merging!

@DanielRosenwasser
Copy link
Member

Tags: void parameters void-typed parameters optional

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.

4 participants