-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Require all parameters in JS #35531
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
Require all parameters in JS #35531
Conversation
This is an experiment in fixing #31888. This is the simplest experiment, which requires all parameters to be provided in JS, same as TS. If this doesn't break the user tests that are written in JS too badly, then I won't proceed to the more complex experiments, which are to require all paremeters for contextually typed functions, or to require all parameters when `"noImplicitAny": true`.
@typescript-bot user test this |
... @typescript-bot user test this ... ? |
@typescript-bot user test this |
Heya @weswigham, I've started to run the parallelized community code test suite on this PR at 7aa5a80. You can monitor the build here. It should now contribute to this PR's status checks. |
Looks like azure functions broke their old |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
Some brief observations. I haven't made any decisions yet:
|
I looked at the webpack errors. The problem is that Javascript has no built-in way to denote optional parameters. If the average function in a ts-checked codebase is not annotated, which is true of webpack, its signature will look like this: I'm going to look at other options. Using |
Well, a probably-incorrect version is quite easy. It doesn't make any tests fail, but asking for a contextual type in the middle of Let's see what the user tests look like: |
Alternatively: Treat any like |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
@weswigham I don't understand, can you explain more? |
Today, when we encounter |
Summary of requiring contextual type in order to fix arity:
Overall I think this is a good compromise. I don't trust the implementation though. @weswigham can you see ways that asking for contextual type in getSignatureFromDeclaration might result in circularities? |
I'm punting this to 3.9, since (1) it is intentionally breaky (though not badly) (2) I still don't trust the implementation. @weswigham you and I should try to step through an example together and convince ourselves that we can't get caught in a circularity. |
This PR hasn't seen any activity for quite a while, so I'm going to close it to keep the number of open PRs manageable. Feel free to open a fresh PR or continue the discussion here. (Also, it's redundant with a change @weswigham merged last month.) |
This is an experiment in fixing #31888. This is the simplest experiment, which requires all parameters to be provided in JS, same as TS. If this doesn't break the user tests that are written in JS too badly, then I won't proceed to the more complex experiments, which are to require all paremeters for contextually typed functions, or to require all parameters when
"noImplicitAny": true
.