Skip to content

Commit b43f9dd

Browse files
committed
add extra test case
1 parent d29a82a commit b43f9dd

File tree

4 files changed

+172
-0
lines changed

4 files changed

+172
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//// [tests/cases/compiler/declarationEmitGenericTypeParamerSerialization3.ts] ////
2+
3+
//// [declarationEmitGenericTypeParamerSerialization3.ts]
4+
function mixin<T extends { new (...args: any[]): {} }>(superclass: T) {
5+
return class extends superclass {};
6+
}
7+
8+
export function wrapper<T>(value: T) {
9+
class BaseClass {
10+
accessor name = value;
11+
}
12+
return class MyClass extends mixin(BaseClass) {
13+
accessor name = value;
14+
}
15+
}
16+
17+
export const Cls = wrapper("test");
18+
19+
20+
//// [declarationEmitGenericTypeParamerSerialization3.js]
21+
function mixin(superclass) {
22+
return class extends superclass {
23+
};
24+
}
25+
export function wrapper(value) {
26+
class BaseClass {
27+
accessor name = value;
28+
}
29+
return class MyClass extends mixin(BaseClass) {
30+
accessor name = value;
31+
};
32+
}
33+
export const Cls = wrapper("test");
34+
35+
36+
//// [declarationEmitGenericTypeParamerSerialization3.d.ts]
37+
export declare function wrapper<T>(value: T): {
38+
new (): {
39+
get name(): T;
40+
set name(arg: T);
41+
};
42+
};
43+
export declare const Cls: {
44+
new (): {
45+
get name(): string;
46+
set name(arg: string);
47+
};
48+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//// [tests/cases/compiler/declarationEmitGenericTypeParamerSerialization3.ts] ////
2+
3+
=== declarationEmitGenericTypeParamerSerialization3.ts ===
4+
function mixin<T extends { new (...args: any[]): {} }>(superclass: T) {
5+
>mixin : Symbol(mixin, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 0, 0))
6+
>T : Symbol(T, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 0, 15))
7+
>args : Symbol(args, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 0, 32))
8+
>superclass : Symbol(superclass, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 0, 55))
9+
>T : Symbol(T, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 0, 15))
10+
11+
return class extends superclass {};
12+
>superclass : Symbol(superclass, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 0, 55))
13+
}
14+
15+
export function wrapper<T>(value: T) {
16+
>wrapper : Symbol(wrapper, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 2, 1))
17+
>T : Symbol(T, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 4, 24))
18+
>value : Symbol(value, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 4, 27))
19+
>T : Symbol(T, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 4, 24))
20+
21+
class BaseClass {
22+
>BaseClass : Symbol(BaseClass, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 4, 38))
23+
24+
accessor name = value;
25+
>name : Symbol(BaseClass.name, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 5, 19))
26+
>value : Symbol(value, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 4, 27))
27+
}
28+
return class MyClass extends mixin(BaseClass) {
29+
>MyClass : Symbol(MyClass, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 8, 8))
30+
>mixin : Symbol(mixin, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 0, 0))
31+
>BaseClass : Symbol(BaseClass, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 4, 38))
32+
33+
accessor name = value;
34+
>name : Symbol(MyClass.name, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 8, 49))
35+
>value : Symbol(value, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 4, 27))
36+
}
37+
}
38+
39+
export const Cls = wrapper("test");
40+
>Cls : Symbol(Cls, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 13, 12))
41+
>wrapper : Symbol(wrapper, Decl(declarationEmitGenericTypeParamerSerialization3.ts, 2, 1))
42+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//// [tests/cases/compiler/declarationEmitGenericTypeParamerSerialization3.ts] ////
2+
3+
=== declarationEmitGenericTypeParamerSerialization3.ts ===
4+
function mixin<T extends { new (...args: any[]): {} }>(superclass: T) {
5+
>mixin : <T extends { new (...args: any[]): {}; }>(superclass: T) => { new (...args: any[]): (Anonymous class); prototype: mixin<any>.(Anonymous class); } & T
6+
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7+
>args : any[]
8+
> : ^^^^^
9+
>superclass : T
10+
> : ^
11+
12+
return class extends superclass {};
13+
>class extends superclass {} : { new (...args: any[]): (Anonymous class); prototype: mixin<any>.(Anonymous class); } & T
14+
> : ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
>superclass : {}
16+
> : ^^
17+
}
18+
19+
export function wrapper<T>(value: T) {
20+
>wrapper : <T>(value: T) => typeof MyClass
21+
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^
22+
>value : T
23+
> : ^
24+
25+
class BaseClass {
26+
>BaseClass : BaseClass
27+
> : ^^^^^^^^^
28+
29+
accessor name = value;
30+
>name : T
31+
> : ^
32+
>value : T
33+
> : ^
34+
}
35+
return class MyClass extends mixin(BaseClass) {
36+
>class MyClass extends mixin(BaseClass) { accessor name = value; } : typeof MyClass
37+
> : ^^^^^^^^^^^^^^
38+
>MyClass : typeof MyClass
39+
> : ^^^^^^^^^^^^^^
40+
>mixin(BaseClass) : mixin<typeof BaseClass>.(Anonymous class) & BaseClass
41+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
>mixin : <T_1 extends { new (...args: any[]): {}; }>(superclass: T_1) => { new (...args: any[]): (Anonymous class); prototype: mixin<any>.(Anonymous class); } & T_1
43+
> : ^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44+
>BaseClass : typeof BaseClass
45+
> : ^^^^^^^^^^^^^^^^
46+
47+
accessor name = value;
48+
>name : T
49+
> : ^
50+
>value : T
51+
> : ^
52+
}
53+
}
54+
55+
export const Cls = wrapper("test");
56+
>Cls : typeof MyClass
57+
> : ^^^^^^^^^^^^^^
58+
>wrapper("test") : typeof MyClass
59+
> : ^^^^^^^^^^^^^^
60+
>wrapper : <T>(value: T) => typeof MyClass
61+
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^
62+
>"test" : "test"
63+
> : ^^^^^^
64+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @strict: true
2+
// @target: esnext
3+
// @declaration: true
4+
5+
function mixin<T extends { new (...args: any[]): {} }>(superclass: T) {
6+
return class extends superclass {};
7+
}
8+
9+
export function wrapper<T>(value: T) {
10+
class BaseClass {
11+
accessor name = value;
12+
}
13+
return class MyClass extends mixin(BaseClass) {
14+
accessor name = value;
15+
}
16+
}
17+
18+
export const Cls = wrapper("test");

0 commit comments

Comments
 (0)