TypeScript/tests/baselines/reference/constructorReturningAPrimitive.types
2015-04-15 16:44:20 -07:00

38 lines
634 B
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
constructor() {
return 1;
>1 : number
}
}
var a = new A();
>a : A
>new A() : A
>A : typeof A
class B<T> {
>B : B<T>
>T : T
constructor() {
var x: T;
>x : T
>T : T
return x;
>x : T
}
}
var b = new B<number>();
>b : B<number>
>new B<number>() : B<number>
>B : typeof B