38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
=== tests/cases/compiler/constructorReturningAPrimitive.ts ===
|
|
// technically not allowed by JavaScript but we don't have a 'not-primitive' constraint
|
|
// functionally only possible when your class is otherwise devoid of members so of little consequence in practice
|
|
|
|
class A {
|
|
>A : A, Symbol(A, Decl(constructorReturningAPrimitive.ts, 0, 0))
|
|
|
|
constructor() {
|
|
return 1;
|
|
>1 : number
|
|
}
|
|
}
|
|
|
|
var a = new A();
|
|
>a : A, Symbol(a, Decl(constructorReturningAPrimitive.ts, 9, 3))
|
|
>new A() : A
|
|
>A : typeof A, Symbol(A, Decl(constructorReturningAPrimitive.ts, 0, 0))
|
|
|
|
class B<T> {
|
|
>B : B<T>, Symbol(B, Decl(constructorReturningAPrimitive.ts, 9, 16))
|
|
>T : T, Symbol(T, Decl(constructorReturningAPrimitive.ts, 11, 8))
|
|
|
|
constructor() {
|
|
var x: T;
|
|
>x : T, Symbol(x, Decl(constructorReturningAPrimitive.ts, 13, 11))
|
|
>T : T, Symbol(T, Decl(constructorReturningAPrimitive.ts, 11, 8))
|
|
|
|
return x;
|
|
>x : T, Symbol(x, Decl(constructorReturningAPrimitive.ts, 13, 11))
|
|
}
|
|
}
|
|
|
|
var b = new B<number>();
|
|
>b : B<number>, Symbol(b, Decl(constructorReturningAPrimitive.ts, 18, 3))
|
|
>new B<number>() : B<number>
|
|
>B : typeof B, Symbol(B, Decl(constructorReturningAPrimitive.ts, 9, 16))
|
|
|