-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Instantiate this when used only in type parameter constraints #19655
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
sandersn
merged 4 commits into
master
from
instantiate-this-in-type-parameter-constraints
Nov 15, 2017
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
db88c8e
Check function type parameters for this references
sandersn e0e1a3b
Test:this instantiation in type parameters
sandersn 80d1a42
Merge branch 'master' into instantiate-this-in-type-parameter-constra…
sandersn 0c77b77
Rename and inline functions
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
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//// [thisTypeInFunctions3.ts] | ||
declare class Base { | ||
check<TProp extends this>(prop: TProp): boolean; | ||
} | ||
|
||
class Test extends Base { | ||
m() { | ||
this.check(this); | ||
} | ||
} | ||
|
||
|
||
//// [thisTypeInFunctions3.js] | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var Test = /** @class */ (function (_super) { | ||
__extends(Test, _super); | ||
function Test() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
Test.prototype.m = function () { | ||
this.check(this); | ||
}; | ||
return Test; | ||
}(Base)); |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === | ||
declare class Base { | ||
>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) | ||
|
||
check<TProp extends this>(prop: TProp): boolean; | ||
>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) | ||
>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) | ||
>prop : Symbol(prop, Decl(thisTypeInFunctions3.ts, 1, 30)) | ||
>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) | ||
} | ||
|
||
class Test extends Base { | ||
>Test : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) | ||
>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) | ||
|
||
m() { | ||
>m : Symbol(Test.m, Decl(thisTypeInFunctions3.ts, 4, 25)) | ||
|
||
this.check(this); | ||
>this.check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) | ||
>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) | ||
>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) | ||
>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === | ||
declare class Base { | ||
>Base : Base | ||
|
||
check<TProp extends this>(prop: TProp): boolean; | ||
>check : <TProp extends this>(prop: TProp) => boolean | ||
>TProp : TProp | ||
>prop : TProp | ||
>TProp : TProp | ||
} | ||
|
||
class Test extends Base { | ||
>Test : Test | ||
>Base : Base | ||
|
||
m() { | ||
>m : () => void | ||
|
||
this.check(this); | ||
>this.check(this) : boolean | ||
>this.check : <TProp extends this>(prop: TProp) => boolean | ||
>this : this | ||
>check : <TProp extends this>(prop: TProp) => boolean | ||
>this : this | ||
} | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare class Base { | ||
check<TProp extends this>(prop: TProp): boolean; | ||
} | ||
|
||
class Test extends Base { | ||
m() { | ||
this.check(this); | ||
} | ||
} |
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.
previously the second
this
reference was not assignable toprop: TProp
.