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

Allow trailing params of undefined/unknown/any' to be optional in JS #40057

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

rbuckton
Copy link
Member

This adds on to #27522 by treating trailing parameters whose types are undefined, unknown, or any as optional parameters when checking JS files when strictNullChecks is disabled.

This is intended to address breaks that would have been caused by #39817.

This only affects JS files when strictNullChecks is disabled. In TS files you can easily specify the type for generics, to include void as a possible type, and if you are working in JS files with strictNullChecks enabled you will already often need to use JSDoc annotations to define the contextual types for expressions.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 14, 2020
@rbuckton
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 14, 2020

Heya @rbuckton, I've started to run the extended test suite on this PR at 5fdf814. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 14, 2020

Heya @rbuckton, I've started to run the parallelized community code test suite on this PR at 5fdf814. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@rbuckton
Copy link
Member Author

@sandersn In the design meeting @DanielRosenwasser mentioned you might want to look at this given that it involves JS checking and strictNullChecks.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

I think this is a good idea, although we now have a bit of a matrix going on for JS:

strict: false -- untyped functions don't require arguments, trailing any/void/undefined aren't required either
noImplicitAny: true -- untyped functions DO require arguments, except trailing any/void/undefined
strictNullChecks: true -- untyped functions don't require arguments, typed ones do
strict: true -- just like TS.

This is the right behaviour, I just don't relish explaining it.

@rbuckton rbuckton merged commit 598e9b2 into master Aug 20, 2020
@rbuckton rbuckton deleted the autoOptionalParams branch August 20, 2020 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants