81 lines
No EOL
2.3 KiB
Text
81 lines
No EOL
2.3 KiB
Text
tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
|
|
|
|
==== tests/cases/compiler/returnInConstructor1.ts (4 errors) ====
|
|
class A {
|
|
foo() { }
|
|
constructor() {
|
|
return;
|
|
}
|
|
}
|
|
|
|
class B {
|
|
foo() { }
|
|
constructor() {
|
|
return 1; // error
|
|
~
|
|
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
}
|
|
}
|
|
|
|
class C {
|
|
foo() { }
|
|
constructor() {
|
|
return this;
|
|
}
|
|
}
|
|
|
|
class D {
|
|
foo() { }
|
|
constructor() {
|
|
return "test"; // error
|
|
~~~~~~
|
|
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
}
|
|
}
|
|
|
|
class E {
|
|
public foo: number;
|
|
constructor() {
|
|
return { foo: 1 };
|
|
}
|
|
}
|
|
|
|
class F {
|
|
public foo: string;
|
|
constructor() {
|
|
return { foo: 1 }; //error
|
|
~~~~~~~~~~
|
|
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
}
|
|
}
|
|
|
|
class G {
|
|
private test: number;
|
|
public test1() { }
|
|
foo() { }
|
|
constructor() {
|
|
this.test = 2;
|
|
}
|
|
}
|
|
|
|
class H extends F {
|
|
constructor() {
|
|
super();
|
|
return new G(); //error
|
|
~~~~~~~
|
|
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
|
}
|
|
}
|
|
|
|
class I extends G {
|
|
constructor() {
|
|
super();
|
|
return new G();
|
|
}
|
|
}
|
|
|
|
|