Test:this instantiation in type parameters
Make sure that `this` gets instantiated when it's used as a constraint of a type parameter, and nowhere else in a signature.
This commit is contained in:
parent
db88c8eac2
commit
e0e1a3b078
33
tests/baselines/reference/thisTypeInFunctions3.js
Normal file
33
tests/baselines/reference/thisTypeInFunctions3.js
Normal file
|
@ -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));
|
26
tests/baselines/reference/thisTypeInFunctions3.symbols
Normal file
26
tests/baselines/reference/thisTypeInFunctions3.symbols
Normal file
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
27
tests/baselines/reference/thisTypeInFunctions3.types
Normal file
27
tests/baselines/reference/thisTypeInFunctions3.types
Normal file
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
declare class Base {
|
||||
check<TProp extends this>(prop: TProp): boolean;
|
||||
}
|
||||
|
||||
class Test extends Base {
|
||||
m() {
|
||||
this.check(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue