TypeScript/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt
2014-07-12 17:30:19 -07:00

40 lines
1 KiB
Plaintext

==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (2 errors) ====
// a class constructor may return an expression, it must be assignable to the class instance type to be valid
class C {
constructor() {
return 1;
}
}
class D {
x: number;
constructor() {
return 1; // error
~
!!! Return type of constructor signature must be assignable to the instance type of the class
}
}
class E {
x: number;
constructor() {
return { x: 1 };
}
}
class F<T> {
x: T;
constructor() {
return { x: 1 }; // error
~~~~~~~~
!!! Return type of constructor signature must be assignable to the instance type of the class
}
}
class G<T> {
x: T;
constructor() {
return { x: <T>null };
}
}