A function should be context-sensitive if its return expression is#17697
Merged
4 commits merged intoAug 10, 2017
Merged
Conversation
rbuckton
reviewed
Aug 9, 2017
| if (node.kind !== SyntaxKind.ArrowFunction) { | ||
| // If the first parameter is not an explicit 'this' parameter, then the function has | ||
| // an implicit 'this' parameter which is subject to contextual typing. Otherwise we | ||
| // know that all parameters (including 'this') have type annotations and nothing is |
Contributor
There was a problem hiding this comment.
Is this comment still accurate?
Member
There was a problem hiding this comment.
"nothing is subject to contextual typing" should change to read "only the return type could still be subject to contextual typing".
sandersn
reviewed
Aug 9, 2017
| const parameter = firstOrUndefined(node.parameters); | ||
| return !(parameter && parameterIsThisKeyword(parameter)); | ||
|
|
||
| // TODO(anhans): A block should be context-sensitive if it has a context-sentitive return value. |
Author
There was a problem hiding this comment.
(This is a response to comment above this -- github won't let me respond to that for some reason.) I'll just remove the second half of this comment since it doesn't add much that isn't already clear from reading the function's code.
| if (node.kind !== SyntaxKind.ArrowFunction) { | ||
| // If the first parameter is not an explicit 'this' parameter, then the function has | ||
| // an implicit 'this' parameter which is subject to contextual typing. Otherwise we | ||
| // know that all parameters (including 'this') have type annotations and nothing is |
Member
There was a problem hiding this comment.
"nothing is subject to contextual typing" should change to read "only the return type could still be subject to contextual typing".
added 2 commits
August 9, 2017 14:21
Contributor
|
Can you address the merge conflicts? |
rbuckton
approved these changes
Aug 9, 2017
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17586
If we're going to do this, we should also consider caching this function, since it gets called a lot.