Skip to content

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 46 commits into from
Apr 7, 2016
Merged
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 Jan 29, 2016
d8a77c0
Check this type in functions.
sandersn Jan 29, 2016
a639b71
Skip emit of this types as first parameter.
sandersn Jan 29, 2016
9bd7afb
Add new error message and strictThis flag
sandersn Jan 29, 2016
ca16209
Make compiler strictThis clean.
sandersn Jan 29, 2016
22e571f
Add services support for this types.
sandersn Jan 29, 2016
5fe8478
Add overloads for Function.apply/call/bind
sandersn Jan 29, 2016
04e7d81
Add tests and baselines for this-function types.
sandersn Jan 29, 2016
a4f1154
Fix free function bug in cachingInServerLSHost
sandersn Jan 29, 2016
d030889
Update baselines
sandersn Jan 29, 2016
675e081
Make this-type of bind's return explicit
sandersn Feb 2, 2016
f6361ce
Undo strictThis-clean changes
sandersn Feb 3, 2016
8032b06
Merge branch 'master' into this-function-types
sandersn Feb 3, 2016
0af56c0
Update error numbers in new tests after merge
sandersn Feb 3, 2016
8c87da5
First round of review comments addressed.
sandersn Feb 4, 2016
2f74da1
Add specific error messages for out-of-place this
sandersn Feb 5, 2016
71488fc
Refactorings from review comments
sandersn Feb 5, 2016
5821b87
Do not contextually type object callee arguments
sandersn Feb 5, 2016
80de700
Get contextual type of this parameter correctly
sandersn Feb 6, 2016
fa59875
Improve display and contextual typing of `this`
sandersn Feb 8, 2016
738713b
Improve error reporting
sandersn Feb 8, 2016
41bb446
Revert unioning of this argument types
sandersn Feb 9, 2016
a014edf
Address more comments and remove temp test.
sandersn Feb 16, 2016
e7aa7e4
Merge branch 'master' into this-function-types
sandersn Feb 16, 2016
482accc
Union this-types of unioned call signatures
sandersn Mar 8, 2016
7b531fc
Check this expressions in object literal methods
sandersn Mar 9, 2016
4012587
Update baselines: 'this' in object literal methods
sandersn Mar 9, 2016
3297824
Add missed update of thisInObjectLiterals baseline
sandersn Mar 9, 2016
fa22250
Merge branch 'master' into this-function-types
sandersn Mar 9, 2016
3a46e72
After merge, update error numbers in baselines
sandersn Mar 9, 2016
1032cc5
Rename --strictThis to --strictThisChecks
sandersn Mar 11, 2016
c9f5f3d
Remove --strictThisChecks
sandersn Mar 25, 2016
a91cdcc
Add --noImplicitThis flag
sandersn Mar 25, 2016
9e5f260
Merge branch 'master' into this-function-types
sandersn Mar 28, 2016
f64110a
Update baselines after merging from master
sandersn Mar 28, 2016
0113ad5
Error on all uses of this that are implicitly any
sandersn Mar 30, 2016
e4ed7f9
Address PR comments
sandersn Mar 30, 2016
0060b4d
Test that signature help doesn't show 'this'
sandersn Mar 31, 2016
da98258
Improve error messages and code style
sandersn Mar 31, 2016
ce68932
Merge branch 'master' into this-function-types
sandersn Mar 31, 2016
81f0d86
Fix up baselines and missing , after merge
sandersn Mar 31, 2016
4197a30
Improve error messages and always return any from newed functions
sandersn Mar 31, 2016
9e5fba6
Prepend 'the' to a couple of ambiguous messages.
sandersn Apr 1, 2016
2a9f39b
Forbid ConstructType as part of 'no this in constructors'
sandersn Apr 1, 2016
921d5f8
Fix == typo and add object literal 'this' test
sandersn Apr 1, 2016
6c735b5
Add contextual typing test with `this` specified
sandersn Apr 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make this-type of bind's return explicit
  • Loading branch information
sandersn committed Feb 2, 2016
commit 675e0816d40cbe1fcd269dc98fff5e8e19bbb9cd
2 changes: 1 addition & 1 deletion src/lib/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

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 and U?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T is the function's this 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>?

bind(this: Function, thisArg: any, ...argArray: any[]): any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you need the explicit this-arg?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I would like this to show up in the quick info. It's quite relevant to this method.
  2. I want to say this: Function instead of this: this because it's a smaller type (thus, easier to call, harder to implement). I hope you can't monkey patch bind so implementation of bind shouldn't be an issue ... I'll go see what I can learn about that. It seems like something people might actually do in javascript.
  3. this: Function is easier to read than this: this for first-time readers of this parameters.
  4. Uniformity with the first overload.


prototype: any;
Expand Down