TypeScript/tests/baselines/reference/returnStatements.types

81 lines
2.8 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/statements/returnStatements/returnStatements.ts ===
// all the following should be valid
function fn1(): number { return 1; }
2015-04-13 23:01:57 +02:00
>fn1 : () => number, Symbol(fn1, Decl(returnStatements.ts, 0, 0))
2015-04-13 21:36:11 +02:00
>1 : number
2014-08-15 23:33:16 +02:00
function fn2(): string { return ''; }
2015-04-13 23:01:57 +02:00
>fn2 : () => string, Symbol(fn2, Decl(returnStatements.ts, 1, 36))
2015-04-13 21:36:11 +02:00
>'' : string
2014-08-15 23:33:16 +02:00
function fn3(): void { return undefined; }
2015-04-13 23:01:57 +02:00
>fn3 : () => void, Symbol(fn3, Decl(returnStatements.ts, 2, 37))
>undefined : undefined, Symbol(undefined)
2014-08-15 23:33:16 +02:00
function fn4(): void { return; }
2015-04-13 23:01:57 +02:00
>fn4 : () => void, Symbol(fn4, Decl(returnStatements.ts, 3, 42))
2014-08-15 23:33:16 +02:00
function fn5(): boolean { return true; }
2015-04-13 23:01:57 +02:00
>fn5 : () => boolean, Symbol(fn5, Decl(returnStatements.ts, 4, 32))
2015-04-13 21:36:11 +02:00
>true : boolean
2014-08-15 23:33:16 +02:00
function fn6(): Date { return new Date(12); }
2015-04-13 23:01:57 +02:00
>fn6 : () => Date, Symbol(fn6, Decl(returnStatements.ts, 5, 40))
>Date : Date, Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
2014-08-15 23:33:16 +02:00
>new Date(12) : Date
2015-04-13 23:01:57 +02:00
>Date : DateConstructor, Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
2015-04-13 21:36:11 +02:00
>12 : number
2014-08-15 23:33:16 +02:00
function fn7(): any { return null; }
2015-04-13 23:01:57 +02:00
>fn7 : () => any, Symbol(fn7, Decl(returnStatements.ts, 6, 45))
2015-04-13 21:36:11 +02:00
>null : null
2014-08-15 23:33:16 +02:00
function fn8(): any { return; } // OK, eq. to 'return undefined'
2015-04-13 23:01:57 +02:00
>fn8 : () => any, Symbol(fn8, Decl(returnStatements.ts, 7, 36))
2014-08-15 23:33:16 +02:00
interface I { id: number }
2015-04-13 23:01:57 +02:00
>I : I, Symbol(I, Decl(returnStatements.ts, 8, 31))
>id : number, Symbol(id, Decl(returnStatements.ts, 10, 13))
2014-08-15 23:33:16 +02:00
class C implements I {
2015-04-13 23:01:57 +02:00
>C : C, Symbol(C, Decl(returnStatements.ts, 10, 26))
>I : I, Symbol(I, Decl(returnStatements.ts, 8, 31))
2014-08-15 23:33:16 +02:00
id: number;
2015-04-13 23:01:57 +02:00
>id : number, Symbol(id, Decl(returnStatements.ts, 11, 22))
2014-08-15 23:33:16 +02:00
dispose() {}
2015-04-13 23:01:57 +02:00
>dispose : () => void, Symbol(dispose, Decl(returnStatements.ts, 12, 15))
2014-08-15 23:33:16 +02:00
}
class D extends C {
2015-04-13 23:01:57 +02:00
>D : D, Symbol(D, Decl(returnStatements.ts, 14, 1))
>C : C, Symbol(C, Decl(returnStatements.ts, 10, 26))
2014-08-15 23:33:16 +02:00
name: string;
2015-04-13 23:01:57 +02:00
>name : string, Symbol(name, Decl(returnStatements.ts, 15, 19))
2014-08-15 23:33:16 +02:00
}
function fn10(): I { return { id: 12 }; }
2015-04-13 23:01:57 +02:00
>fn10 : () => I, Symbol(fn10, Decl(returnStatements.ts, 17, 1))
>I : I, Symbol(I, Decl(returnStatements.ts, 8, 31))
2014-08-15 23:33:16 +02:00
>{ id: 12 } : { id: number; }
2015-04-13 23:01:57 +02:00
>id : number, Symbol(id, Decl(returnStatements.ts, 18, 29))
2015-04-13 21:36:11 +02:00
>12 : number
2014-08-15 23:33:16 +02:00
function fn11(): I { return new C(); }
2015-04-13 23:01:57 +02:00
>fn11 : () => I, Symbol(fn11, Decl(returnStatements.ts, 18, 41))
>I : I, Symbol(I, Decl(returnStatements.ts, 8, 31))
2014-08-15 23:33:16 +02:00
>new C() : C
2015-04-13 23:01:57 +02:00
>C : typeof C, Symbol(C, Decl(returnStatements.ts, 10, 26))
2014-08-15 23:33:16 +02:00
function fn12(): C { return new D(); }
2015-04-13 23:01:57 +02:00
>fn12 : () => C, Symbol(fn12, Decl(returnStatements.ts, 20, 38))
>C : C, Symbol(C, Decl(returnStatements.ts, 10, 26))
2014-08-15 23:33:16 +02:00
>new D() : D
2015-04-13 23:01:57 +02:00
>D : typeof D, Symbol(D, Decl(returnStatements.ts, 14, 1))
2014-08-15 23:33:16 +02:00
function fn13(): C { return null; }
2015-04-13 23:01:57 +02:00
>fn13 : () => C, Symbol(fn13, Decl(returnStatements.ts, 21, 38))
>C : C, Symbol(C, Decl(returnStatements.ts, 10, 26))
2015-04-13 21:36:11 +02:00
>null : null
2014-08-15 23:33:16 +02:00