-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Typed 'this' in object literal methods #14141
Merged
Merged
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
f6a3a3f
Use '__this__' property in contextual type to indicate type of 'this'
ahejlsberg 8cd6c5d
Introduce ThisType<T> marker interface
ahejlsberg 2ca6164
Default contextual 'this' type is containing object literal
ahejlsberg e512376
Update tests
ahejlsberg d7e153d
Accept new baselines
ahejlsberg fe32bb7
Merge branch 'master' into contextualThisType
ahejlsberg 27346b1
Accept new baselines
ahejlsberg e3a0687
Contextual this in 'obj.xxx = function(...)' or 'obj[xxx] = function(…
ahejlsberg 168d367
Contextually type 'this' in accessors of object literals
ahejlsberg c2d8a59
Accept new baselines
ahejlsberg ec292c9
Update test
ahejlsberg 9b6b6cc
Fix linting error
ahejlsberg 9dc2bae
Use contextual type of object literal as 'this' in methods
ahejlsberg 16f4030
Accept new baselines
ahejlsberg 20b4523
Rename applyToContextualType to mapType and remove old mapType
ahejlsberg 6fdd929
Update test
ahejlsberg cd87d90
Update comment
ahejlsberg 5bda48b
Add tests
ahejlsberg 993397b
Introduce CheckMode enum and getContextualMapper() function
ahejlsberg ff2cfd2
Update test
ahejlsberg c87c124
Accept new baselines
ahejlsberg ee7b93c
Merge branch 'master' into contextualThisType
ahejlsberg 21c4300
Enable new behavior only in --noImplicitThis mode
ahejlsberg 25738a8
Update tests
ahejlsberg f77cd8e
Accept new baselines
ahejlsberg 9d1b325
Update another test
ahejlsberg 7561cdf
Add ThisType<any> to Object.{create|defineProperty|defineProperties}
ahejlsberg 258bb4f
Accept new baselines
ahejlsberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
shouldn't
applyToContextualType
just be namedmapType
and replacemapType
? It doesn't do anything specific to contextual types that I could see, and it's better than the currentmapType
because it skips return values ofundefined
. #ResolvedThere 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.
Yes, that makes sense.