-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Contextual typing of partially annotated signatures #11673
Conversation
OK, I merged the tests from #11529. |
Regression test for #10972
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment — there is a utility for checking the this
parameter already.
// know that all parameters (including 'this') have type annotations and nothing is | ||
// subject to contextual typing. | ||
const parameter = firstOrUndefined(node.parameters); | ||
return !(parameter && parameter.name.kind === SyntaxKind.Identifier && (<Identifier>parameter.name).text === "this"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be written as !parameterIsThisKeyword(firstOrUndefined(node.parameters))
This PR supersedes #11529 and #11600. Thanks to @HerringtonDarkholme for the original idea regarding type inference and contextual typing of partially annotated signatures.
We probably want to move the tests over from #11529. @sandersn Maybe you want to look at that?
Fixes #4241.
Fixes #9648.
Fixes #10850.
Fixes #10972.