Skip to content

Commit d262567

Browse files
authored
Add test case from microsoft#14439 (microsoft#17627)
1 parent 3deb39b commit d262567

4 files changed

Lines changed: 255 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//// [mixingApparentTypeOverrides.ts]
2+
type Constructor<T> = new(...args: any[]) => T;
3+
function Tagged<T extends Constructor<{}>>(Base: T) {
4+
return class extends Base {
5+
_tag: string;
6+
constructor(...args: any[]) {
7+
super(...args);
8+
this._tag = "";
9+
}
10+
};
11+
}
12+
13+
class A {
14+
toString () {
15+
return "class A";
16+
}
17+
}
18+
19+
class B extends Tagged(A) {
20+
toString () { // Should not be an error
21+
return "class B";
22+
}
23+
}
24+
25+
class C extends A {
26+
toString () { // Should not be an error
27+
return "class C";
28+
}
29+
}
30+
31+
//// [mixingApparentTypeOverrides.js]
32+
var __extends = (this && this.__extends) || (function () {
33+
var extendStatics = Object.setPrototypeOf ||
34+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36+
return function (d, b) {
37+
extendStatics(d, b);
38+
function __() { this.constructor = d; }
39+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40+
};
41+
})();
42+
function Tagged(Base) {
43+
return (function (_super) {
44+
__extends(class_1, _super);
45+
function class_1() {
46+
var args = [];
47+
for (var _i = 0; _i < arguments.length; _i++) {
48+
args[_i] = arguments[_i];
49+
}
50+
var _this = _super.apply(this, args) || this;
51+
_this._tag = "";
52+
return _this;
53+
}
54+
return class_1;
55+
}(Base));
56+
}
57+
var A = (function () {
58+
function A() {
59+
}
60+
A.prototype.toString = function () {
61+
return "class A";
62+
};
63+
return A;
64+
}());
65+
var B = (function (_super) {
66+
__extends(B, _super);
67+
function B() {
68+
return _super !== null && _super.apply(this, arguments) || this;
69+
}
70+
B.prototype.toString = function () {
71+
return "class B";
72+
};
73+
return B;
74+
}(Tagged(A)));
75+
var C = (function (_super) {
76+
__extends(C, _super);
77+
function C() {
78+
return _super !== null && _super.apply(this, arguments) || this;
79+
}
80+
C.prototype.toString = function () {
81+
return "class C";
82+
};
83+
return C;
84+
}(A));
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
=== tests/cases/compiler/mixingApparentTypeOverrides.ts ===
2+
type Constructor<T> = new(...args: any[]) => T;
3+
>Constructor : Symbol(Constructor, Decl(mixingApparentTypeOverrides.ts, 0, 0))
4+
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 0, 17))
5+
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 0, 26))
6+
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 0, 17))
7+
8+
function Tagged<T extends Constructor<{}>>(Base: T) {
9+
>Tagged : Symbol(Tagged, Decl(mixingApparentTypeOverrides.ts, 0, 47))
10+
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
11+
>Constructor : Symbol(Constructor, Decl(mixingApparentTypeOverrides.ts, 0, 0))
12+
>Base : Symbol(Base, Decl(mixingApparentTypeOverrides.ts, 1, 43))
13+
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
14+
15+
return class extends Base {
16+
>Base : Symbol(Base, Decl(mixingApparentTypeOverrides.ts, 1, 43))
17+
18+
_tag: string;
19+
>_tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
20+
21+
constructor(...args: any[]) {
22+
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 4, 16))
23+
24+
super(...args);
25+
>super : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
26+
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 4, 16))
27+
28+
this._tag = "";
29+
>this._tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
30+
>this : Symbol((Anonymous class), Decl(mixingApparentTypeOverrides.ts, 2, 8))
31+
>_tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
32+
}
33+
};
34+
}
35+
36+
class A {
37+
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
38+
39+
toString () {
40+
>toString : Symbol(A.toString, Decl(mixingApparentTypeOverrides.ts, 11, 9))
41+
42+
return "class A";
43+
}
44+
}
45+
46+
class B extends Tagged(A) {
47+
>B : Symbol(B, Decl(mixingApparentTypeOverrides.ts, 15, 1))
48+
>Tagged : Symbol(Tagged, Decl(mixingApparentTypeOverrides.ts, 0, 47))
49+
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
50+
51+
toString () { // Should not be an error
52+
>toString : Symbol(B.toString, Decl(mixingApparentTypeOverrides.ts, 17, 27))
53+
54+
return "class B";
55+
}
56+
}
57+
58+
class C extends A {
59+
>C : Symbol(C, Decl(mixingApparentTypeOverrides.ts, 21, 1))
60+
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
61+
62+
toString () { // Should not be an error
63+
>toString : Symbol(C.toString, Decl(mixingApparentTypeOverrides.ts, 23, 19))
64+
65+
return "class C";
66+
}
67+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
=== tests/cases/compiler/mixingApparentTypeOverrides.ts ===
2+
type Constructor<T> = new(...args: any[]) => T;
3+
>Constructor : Constructor<T>
4+
>T : T
5+
>args : any[]
6+
>T : T
7+
8+
function Tagged<T extends Constructor<{}>>(Base: T) {
9+
>Tagged : <T extends Constructor<{}>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
10+
>T : T
11+
>Constructor : Constructor<T>
12+
>Base : T
13+
>T : T
14+
15+
return class extends Base {
16+
>class extends Base { _tag: string; constructor(...args: any[]) { super(...args); this._tag = ""; } } : { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
17+
>Base : {}
18+
19+
_tag: string;
20+
>_tag : string
21+
22+
constructor(...args: any[]) {
23+
>args : any[]
24+
25+
super(...args);
26+
>super(...args) : void
27+
>super : T
28+
>...args : any
29+
>args : any[]
30+
31+
this._tag = "";
32+
>this._tag = "" : ""
33+
>this._tag : string
34+
>this : this
35+
>_tag : string
36+
>"" : ""
37+
}
38+
};
39+
}
40+
41+
class A {
42+
>A : A
43+
44+
toString () {
45+
>toString : () => string
46+
47+
return "class A";
48+
>"class A" : "class A"
49+
}
50+
}
51+
52+
class B extends Tagged(A) {
53+
>B : B
54+
>Tagged(A) : Tagged<typeof A>.(Anonymous class) & A
55+
>Tagged : <T extends Constructor<{}>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
56+
>A : typeof A
57+
58+
toString () { // Should not be an error
59+
>toString : () => string
60+
61+
return "class B";
62+
>"class B" : "class B"
63+
}
64+
}
65+
66+
class C extends A {
67+
>C : C
68+
>A : A
69+
70+
toString () { // Should not be an error
71+
>toString : () => string
72+
73+
return "class C";
74+
>"class C" : "class C"
75+
}
76+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
type Constructor<T> = new(...args: any[]) => T;
2+
function Tagged<T extends Constructor<{}>>(Base: T) {
3+
return class extends Base {
4+
_tag: string;
5+
constructor(...args: any[]) {
6+
super(...args);
7+
this._tag = "";
8+
}
9+
};
10+
}
11+
12+
class A {
13+
toString () {
14+
return "class A";
15+
}
16+
}
17+
18+
class B extends Tagged(A) {
19+
toString () { // Should not be an error
20+
return "class B";
21+
}
22+
}
23+
24+
class C extends A {
25+
toString () { // Should not be an error
26+
return "class C";
27+
}
28+
}

0 commit comments

Comments
 (0)