Skip to content

Commit 89eaf55

Browse files
committed
Added tests
1 parent 43614f6 commit 89eaf55

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [intersectionType_useDefineForClassFields.ts]
2+
type Foo<T> = {
3+
[k in keyof T & string]: any
4+
}
5+
6+
function bar<T>(_p: T): { new(): Foo<T> } {
7+
return null as any;
8+
}
9+
10+
class Baz extends bar({ x: 1 }) {
11+
}
12+
13+
//// [intersectionType_useDefineForClassFields.js]
14+
function bar(_p) {
15+
return null;
16+
}
17+
class Baz extends bar({ x: 1 }) {
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/compiler/intersectionType_useDefineForClassFields.ts ===
2+
type Foo<T> = {
3+
>Foo : Symbol(Foo, Decl(intersectionType_useDefineForClassFields.ts, 0, 0))
4+
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 0, 9))
5+
6+
[k in keyof T & string]: any
7+
>k : Symbol(k, Decl(intersectionType_useDefineForClassFields.ts, 1, 5))
8+
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 0, 9))
9+
}
10+
11+
function bar<T>(_p: T): { new(): Foo<T> } {
12+
>bar : Symbol(bar, Decl(intersectionType_useDefineForClassFields.ts, 2, 1))
13+
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 4, 13))
14+
>_p : Symbol(_p, Decl(intersectionType_useDefineForClassFields.ts, 4, 16))
15+
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 4, 13))
16+
>Foo : Symbol(Foo, Decl(intersectionType_useDefineForClassFields.ts, 0, 0))
17+
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 4, 13))
18+
19+
return null as any;
20+
}
21+
22+
class Baz extends bar({ x: 1 }) {
23+
>Baz : Symbol(Baz, Decl(intersectionType_useDefineForClassFields.ts, 6, 1))
24+
>bar : Symbol(bar, Decl(intersectionType_useDefineForClassFields.ts, 2, 1))
25+
>x : Symbol(x, Decl(intersectionType_useDefineForClassFields.ts, 8, 23))
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/compiler/intersectionType_useDefineForClassFields.ts ===
2+
type Foo<T> = {
3+
>Foo : Foo<T>
4+
5+
[k in keyof T & string]: any
6+
}
7+
8+
function bar<T>(_p: T): { new(): Foo<T> } {
9+
>bar : <T>(_p: T) => { new (): Foo<T>;}
10+
>_p : T
11+
12+
return null as any;
13+
>null as any : any
14+
>null : null
15+
}
16+
17+
class Baz extends bar({ x: 1 }) {
18+
>Baz : Baz
19+
>bar({ x: 1 }) : Foo<{ x: number; }>
20+
>bar : <T>(_p: T) => new () => Foo<T>
21+
>{ x: 1 } : { x: number; }
22+
>x : number
23+
>1 : 1
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @target: ESNext
2+
// @useDefineForClassFields: true
3+
4+
type Foo<T> = {
5+
[k in keyof T & string]: any
6+
}
7+
8+
function bar<T>(_p: T): { new(): Foo<T> } {
9+
return null as any;
10+
}
11+
12+
class Baz extends bar({ x: 1 }) {
13+
}

0 commit comments

Comments
 (0)