Skip to content

Commit f56298a

Browse files
committed
Add a test
1 parent f37fc1d commit f56298a

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [typeArgumentInferenceWithClassExpression.ts]
2+
function foo<T>(x = class { static prop: T }): T {
3+
return undefined;
4+
}
5+
6+
foo(class { static prop = "hello" }).length;
7+
8+
//// [typeArgumentInferenceWithClassExpression.js]
9+
function foo(x) {
10+
if (x === void 0) { x = (function () {
11+
function class_1() {
12+
}
13+
return class_1;
14+
})(); }
15+
return undefined;
16+
}
17+
foo((function () {
18+
function class_2() {
19+
}
20+
class_2.prop = "hello";
21+
return class_2;
22+
})()).length;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression.ts ===
2+
function foo<T>(x = class { static prop: T }): T {
3+
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 0))
4+
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 13))
5+
>x : Symbol(x, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 16))
6+
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 27))
7+
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 13))
8+
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 13))
9+
10+
return undefined;
11+
>undefined : Symbol(undefined)
12+
}
13+
14+
foo(class { static prop = "hello" }).length;
15+
>foo(class { static prop = "hello" }).length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
16+
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression.ts, 0, 0))
17+
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression.ts, 4, 11))
18+
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
19+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression.ts ===
2+
function foo<T>(x = class { static prop: T }): T {
3+
>foo : <T>(x?: typeof (Anonymous class)) => T
4+
>T : T
5+
>x : typeof (Anonymous class)
6+
>class { static prop: T } : typeof (Anonymous class)
7+
>prop : T
8+
>T : T
9+
>T : T
10+
11+
return undefined;
12+
>undefined : undefined
13+
}
14+
15+
foo(class { static prop = "hello" }).length;
16+
>foo(class { static prop = "hello" }).length : number
17+
>foo(class { static prop = "hello" }) : string
18+
>foo : <T>(x?: typeof (Anonymous class)) => T
19+
>class { static prop = "hello" } : typeof (Anonymous class)
20+
>prop : string
21+
>"hello" : string
22+
>length : number
23+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function foo<T>(x = class { static prop: T }): T {
2+
return undefined;
3+
}
4+
5+
foo(class { static prop = "hello" }).length;

0 commit comments

Comments
 (0)