TypeScript/tests/baselines/reference/constructorReturningAPrimitive.types

38 lines
634 B
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== 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
2014-08-15 23:33:16 +02:00
constructor() {
return 1;
2015-04-13 21:36:11 +02:00
>1 : number
2014-08-15 23:33:16 +02:00
}
}
var a = new A();
>a : A
2014-08-15 23:33:16 +02:00
>new A() : A
>A : typeof A
2014-08-15 23:33:16 +02:00
class B<T> {
>B : B<T>
>T : T
2014-08-15 23:33:16 +02:00
constructor() {
var x: T;
>x : T
>T : T
2014-08-15 23:33:16 +02:00
return x;
>x : T
2014-08-15 23:33:16 +02:00
}
}
var b = new B<number>();
>b : B<number>
2014-08-15 23:33:16 +02:00
>new B<number>() : B<number>
>B : typeof B
2014-08-15 23:33:16 +02:00