TypeScript/tests/baselines/reference/invalidReturnStatements.errors.txt

45 lines
2.9 KiB
Plaintext
Raw Normal View History

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.
2014-11-05 21:26:03 +01:00
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; }'.
2014-11-05 21:26:03 +01:00
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) ====
2014-07-13 01:04:16 +02:00
// 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.
2014-07-13 01:04:16 +02:00
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.
2014-07-13 01:04:16 +02:00
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.
2014-07-13 01:04:16 +02:00
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.
2014-07-13 01:04:16 +02:00
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 }; }
~~~~~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type '{ id: number; }' is not assignable to type 'D'.
!!! error TS2322: Property 'name' is missing in type '{ id: number; }'.
2014-07-13 01:04:16 +02:00
function fn11(): D { return new C(); }
~~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'C' is not assignable to type 'D'.
!!! error TS2322: Property 'name' is missing in type 'C'.
2014-07-13 01:04:16 +02:00