Merge pull request #6628 from Microsoft/thisTypeAsConstraint
break on 'this' type in hasConstraintReferenceTo
This commit is contained in:
commit
322126d106
5 changed files with 37 additions and 1 deletions
|
@ -4285,7 +4285,7 @@ namespace ts {
|
|||
|
||||
function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
|
||||
let checked: Type[];
|
||||
while (type && type.flags & TypeFlags.TypeParameter && !contains(checked, type)) {
|
||||
while (type && !(type.flags & TypeFlags.ThisType) && type.flags & TypeFlags.TypeParameter && !contains(checked, type)) {
|
||||
if (type === target) {
|
||||
return true;
|
||||
}
|
||||
|
|
14
tests/baselines/reference/thisTypeAsConstraint.js
Normal file
14
tests/baselines/reference/thisTypeAsConstraint.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
//// [thisTypeAsConstraint.ts]
|
||||
class C {
|
||||
public m<T extends this>() {
|
||||
}
|
||||
}
|
||||
|
||||
//// [thisTypeAsConstraint.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m = function () {
|
||||
};
|
||||
return C;
|
||||
}());
|
9
tests/baselines/reference/thisTypeAsConstraint.symbols
Normal file
9
tests/baselines/reference/thisTypeAsConstraint.symbols
Normal file
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/thisTypeAsConstraint.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(thisTypeAsConstraint.ts, 0, 0))
|
||||
|
||||
public m<T extends this>() {
|
||||
>m : Symbol(m, Decl(thisTypeAsConstraint.ts, 0, 9))
|
||||
>T : Symbol(T, Decl(thisTypeAsConstraint.ts, 1, 11))
|
||||
}
|
||||
}
|
9
tests/baselines/reference/thisTypeAsConstraint.types
Normal file
9
tests/baselines/reference/thisTypeAsConstraint.types
Normal file
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/thisTypeAsConstraint.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
public m<T extends this>() {
|
||||
>m : <T extends this>() => void
|
||||
>T : T
|
||||
}
|
||||
}
|
4
tests/cases/compiler/thisTypeAsConstraint.ts
Normal file
4
tests/cases/compiler/thisTypeAsConstraint.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
class C {
|
||||
public m<T extends this>() {
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue