45 lines
No EOL
2.9 KiB
Text
45 lines
No EOL
2.9 KiB
Text
tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(4,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(5,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,29): error TS2322: Type '{ id: number; }' is not assignable to type 'D'.
|
|
Property 'name' is missing in type '{ id: number; }'.
|
|
tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,29): error TS2322: Type 'C' is not assignable to type 'D'.
|
|
Property 'name' is missing in type 'C'.
|
|
|
|
|
|
==== tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts (6 errors) ====
|
|
// all the following should be error
|
|
function fn1(): number { }
|
|
~~~~~~
|
|
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
function fn2(): string { }
|
|
~~~~~~
|
|
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
function fn3(): boolean { }
|
|
~~~~~~~
|
|
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
function fn4(): Date { }
|
|
~~~~
|
|
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
|
function fn7(): any { } // should be valid: any includes void
|
|
|
|
interface I { id: number }
|
|
class C implements I {
|
|
id: number;
|
|
dispose() {}
|
|
}
|
|
class D extends C {
|
|
name: string;
|
|
}
|
|
function fn10(): D { return { id: 12 }; }
|
|
~~~~~~~~~~
|
|
!!! error TS2322: Type '{ id: number; }' is not assignable to type 'D'.
|
|
!!! error TS2322: Property 'name' is missing in type '{ id: number; }'.
|
|
|
|
function fn11(): D { return new C(); }
|
|
~~~~~~~
|
|
!!! error TS2322: Type 'C' is not assignable to type 'D'.
|
|
!!! error TS2322: Property 'name' is missing in type 'C'.
|
|
|
|
|