Improved const extraction for function expressions and arrow functions#32345
Merged
orta merged 2 commits intomicrosoft:masterfrom Sep 11, 2019
Merged
Conversation
…s. The behavior applies if the function: - is contextually typed (because otherwise no type annotation for the variable would have been generated anyway) - is not generic - doesn't have parameters inferred as any If these conditions are met, we add missing parameters type and we add this parameter to the function.
Contributor
Author
|
@RyanCavanaugh @DanielRosenwasser Not sure who to ping about this. If there is anything I can do to move this along let me know. |
orta
approved these changes
Sep 11, 2019
Contributor
orta
left a comment
There was a problem hiding this comment.
Yep, this looks good to me. Sorry it took some time for me to come back round to get it.
The amount of comments made it much easier to grok, thanks! (Will merge after suggestion)
|
|
||
| // ==SCOPE::Extract to constant in enclosing scope== | ||
| const newLocal: (x: number, y: string) => void = (x, y) => x + y; | ||
| const newLocal = (x: number, y: string): string => x + y; |
Fixed typo in comment Co-Authored-By: Orta <orta.therox+github@gmail.com>
Contributor
|
Thanks, looks great. |
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.
The behavior applies if the function:
If these conditions are met, we add missing parameters type and we add this parameter to the function (if the function signature as a
thisparameter).Fixes #32257