-
Notifications
You must be signed in to change notification settings - Fork 12.9k
This function types #6739
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
Merged
Merged
This function types #6739
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
0a968f0
Parse this type using parameter syntax
sandersn d8a77c0
Check this type in functions.
sandersn a639b71
Skip emit of this types as first parameter.
sandersn 9bd7afb
Add new error message and strictThis flag
sandersn ca16209
Make compiler strictThis clean.
sandersn 22e571f
Add services support for this types.
sandersn 5fe8478
Add overloads for Function.apply/call/bind
sandersn 04e7d81
Add tests and baselines for this-function types.
sandersn a4f1154
Fix free function bug in cachingInServerLSHost
sandersn d030889
Update baselines
sandersn 675e081
Make this-type of bind's return explicit
sandersn f6361ce
Undo strictThis-clean changes
sandersn 8032b06
Merge branch 'master' into this-function-types
sandersn 0af56c0
Update error numbers in new tests after merge
sandersn 8c87da5
First round of review comments addressed.
sandersn 2f74da1
Add specific error messages for out-of-place this
sandersn 71488fc
Refactorings from review comments
sandersn 5821b87
Do not contextually type object callee arguments
sandersn 80de700
Get contextual type of this parameter correctly
sandersn fa59875
Improve display and contextual typing of `this`
sandersn 738713b
Improve error reporting
sandersn 41bb446
Revert unioning of this argument types
sandersn a014edf
Address more comments and remove temp test.
sandersn e7aa7e4
Merge branch 'master' into this-function-types
sandersn 482accc
Union this-types of unioned call signatures
sandersn 7b531fc
Check this expressions in object literal methods
sandersn 4012587
Update baselines: 'this' in object literal methods
sandersn 3297824
Add missed update of thisInObjectLiterals baseline
sandersn fa22250
Merge branch 'master' into this-function-types
sandersn 3a46e72
After merge, update error numbers in baselines
sandersn 1032cc5
Rename --strictThis to --strictThisChecks
sandersn c9f5f3d
Remove --strictThisChecks
sandersn a91cdcc
Add --noImplicitThis flag
sandersn 9e5f260
Merge branch 'master' into this-function-types
sandersn f64110a
Update baselines after merging from master
sandersn 0113ad5
Error on all uses of this that are implicitly any
sandersn e4ed7f9
Address PR comments
sandersn 0060b4d
Test that signature help doesn't show 'this'
sandersn da98258
Improve error messages and code style
sandersn ce68932
Merge branch 'master' into this-function-types
sandersn 81f0d86
Fix up baselines and missing , after merge
sandersn 4197a30
Improve error messages and always return any from newed functions
sandersn 9e5fba6
Prepend 'the' to a couple of ambiguous messages.
sandersn 2a9f39b
Forbid ConstructType as part of 'no this in constructors'
sandersn 921d5f8
Fix == typo and add object literal 'this' test
sandersn 6c735b5
Add contextual typing test with `this` specified
sandersn 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
Make this-type of bind's return explicit
- Loading branch information
commit 675e0816d40cbe1fcd269dc98fff5e8e19bbb9cd
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,7 +232,7 @@ interface Function { | |
* @param thisArg An object to which the this keyword can refer inside the new function. | ||
* @param argArray A list of arguments to be passed to the new function. | ||
*/ | ||
bind<T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (...argArray: any[]) => U; | ||
bind<T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (this: void, ...argArray: any[]) => U; | ||
bind(this: Function, thisArg: any, ...argArray: any[]): any; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you need the explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
prototype: any; | ||
|
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.
Wouldn't you want to place some constraint between
T
andU
?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.
T
is the function'sthis
type.U
is the function's return value. There's no relation between them. I don't know TypeScript's conventions for type variable names that well. Would it be easier to read to change this to<TThis, TReturn>
?