Add test case from #14439 (#17627)

This commit is contained in:
Wesley Wigham
2017-08-08 14:44:41 -07:00
committed by GitHub
parent 3deb39bba6
commit d2625678f9
4 changed files with 255 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
//// [mixingApparentTypeOverrides.ts]
type Constructor<T> = new(...args: any[]) => T;
function Tagged<T extends Constructor<{}>>(Base: T) {
return class extends Base {
_tag: string;
constructor(...args: any[]) {
super(...args);
this._tag = "";
}
};
}
class A {
toString () {
return "class A";
}
}
class B extends Tagged(A) {
toString () { // Should not be an error
return "class B";
}
}
class C extends A {
toString () { // Should not be an error
return "class C";
}
}
//// [mixingApparentTypeOverrides.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 __());
};
})();
function Tagged(Base) {
return (function (_super) {
__extends(class_1, _super);
function class_1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, args) || this;
_this._tag = "";
return _this;
}
return class_1;
}(Base));
}
var A = (function () {
function A() {
}
A.prototype.toString = function () {
return "class A";
};
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
B.prototype.toString = function () {
return "class B";
};
return B;
}(Tagged(A)));
var C = (function (_super) {
__extends(C, _super);
function C() {
return _super !== null && _super.apply(this, arguments) || this;
}
C.prototype.toString = function () {
return "class C";
};
return C;
}(A));

View File

@@ -0,0 +1,67 @@
=== tests/cases/compiler/mixingApparentTypeOverrides.ts ===
type Constructor<T> = new(...args: any[]) => T;
>Constructor : Symbol(Constructor, Decl(mixingApparentTypeOverrides.ts, 0, 0))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 0, 17))
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 0, 26))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 0, 17))
function Tagged<T extends Constructor<{}>>(Base: T) {
>Tagged : Symbol(Tagged, Decl(mixingApparentTypeOverrides.ts, 0, 47))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
>Constructor : Symbol(Constructor, Decl(mixingApparentTypeOverrides.ts, 0, 0))
>Base : Symbol(Base, Decl(mixingApparentTypeOverrides.ts, 1, 43))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
return class extends Base {
>Base : Symbol(Base, Decl(mixingApparentTypeOverrides.ts, 1, 43))
_tag: string;
>_tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
constructor(...args: any[]) {
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 4, 16))
super(...args);
>super : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 4, 16))
this._tag = "";
>this._tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
>this : Symbol((Anonymous class), Decl(mixingApparentTypeOverrides.ts, 2, 8))
>_tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
}
};
}
class A {
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
toString () {
>toString : Symbol(A.toString, Decl(mixingApparentTypeOverrides.ts, 11, 9))
return "class A";
}
}
class B extends Tagged(A) {
>B : Symbol(B, Decl(mixingApparentTypeOverrides.ts, 15, 1))
>Tagged : Symbol(Tagged, Decl(mixingApparentTypeOverrides.ts, 0, 47))
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
toString () { // Should not be an error
>toString : Symbol(B.toString, Decl(mixingApparentTypeOverrides.ts, 17, 27))
return "class B";
}
}
class C extends A {
>C : Symbol(C, Decl(mixingApparentTypeOverrides.ts, 21, 1))
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
toString () { // Should not be an error
>toString : Symbol(C.toString, Decl(mixingApparentTypeOverrides.ts, 23, 19))
return "class C";
}
}

View File

@@ -0,0 +1,76 @@
=== tests/cases/compiler/mixingApparentTypeOverrides.ts ===
type Constructor<T> = new(...args: any[]) => T;
>Constructor : Constructor<T>
>T : T
>args : any[]
>T : T
function Tagged<T extends Constructor<{}>>(Base: T) {
>Tagged : <T extends Constructor<{}>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
>T : T
>Constructor : Constructor<T>
>Base : T
>T : T
return class extends Base {
>class extends Base { _tag: string; constructor(...args: any[]) { super(...args); this._tag = ""; } } : { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
>Base : {}
_tag: string;
>_tag : string
constructor(...args: any[]) {
>args : any[]
super(...args);
>super(...args) : void
>super : T
>...args : any
>args : any[]
this._tag = "";
>this._tag = "" : ""
>this._tag : string
>this : this
>_tag : string
>"" : ""
}
};
}
class A {
>A : A
toString () {
>toString : () => string
return "class A";
>"class A" : "class A"
}
}
class B extends Tagged(A) {
>B : B
>Tagged(A) : Tagged<typeof A>.(Anonymous class) & A
>Tagged : <T extends Constructor<{}>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
>A : typeof A
toString () { // Should not be an error
>toString : () => string
return "class B";
>"class B" : "class B"
}
}
class C extends A {
>C : C
>A : A
toString () { // Should not be an error
>toString : () => string
return "class C";
>"class C" : "class C"
}
}

View File

@@ -0,0 +1,28 @@
type Constructor<T> = new(...args: any[]) => T;
function Tagged<T extends Constructor<{}>>(Base: T) {
return class extends Base {
_tag: string;
constructor(...args: any[]) {
super(...args);
this._tag = "";
}
};
}
class A {
toString () {
return "class A";
}
}
class B extends Tagged(A) {
toString () { // Should not be an error
return "class B";
}
}
class C extends A {
toString () { // Should not be an error
return "class C";
}
}