TypeScript/tests/baselines/reference/subtypingWithCallSignatures.types

63 lines
4.3 KiB
Text
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignatures.ts ===
module CallSignature {
2015-04-13 23:01:57 +02:00
>CallSignature : typeof CallSignature, Symbol(CallSignature, Decl(subtypingWithCallSignatures.ts, 0, 0))
2014-08-15 23:33:16 +02:00
declare function foo1(cb: (x: number) => void): typeof cb;
2015-04-13 23:01:57 +02:00
>foo1 : { (cb: (x: number) => void): (x: number) => void; (cb: any): any; }, Symbol(foo1, Decl(subtypingWithCallSignatures.ts, 0, 22), Decl(subtypingWithCallSignatures.ts, 1, 62))
>cb : (x: number) => void, Symbol(cb, Decl(subtypingWithCallSignatures.ts, 1, 26))
>x : number, Symbol(x, Decl(subtypingWithCallSignatures.ts, 1, 31))
>cb : (x: number) => void, Symbol(cb, Decl(subtypingWithCallSignatures.ts, 1, 26))
2014-08-15 23:33:16 +02:00
declare function foo1(cb: any): any;
2015-04-13 23:01:57 +02:00
>foo1 : { (cb: (x: number) => void): (x: number) => void; (cb: any): any; }, Symbol(foo1, Decl(subtypingWithCallSignatures.ts, 0, 22), Decl(subtypingWithCallSignatures.ts, 1, 62))
>cb : any, Symbol(cb, Decl(subtypingWithCallSignatures.ts, 2, 26))
2014-08-15 23:33:16 +02:00
var r = foo1((x: number) => 1); // ok because base returns void
2015-04-13 23:01:57 +02:00
>r : (x: number) => void, Symbol(r, Decl(subtypingWithCallSignatures.ts, 3, 7))
2014-08-15 23:33:16 +02:00
>foo1((x: number) => 1) : (x: number) => void
2015-04-13 23:01:57 +02:00
>foo1 : { (cb: (x: number) => void): (x: number) => void; (cb: any): any; }, Symbol(foo1, Decl(subtypingWithCallSignatures.ts, 0, 22), Decl(subtypingWithCallSignatures.ts, 1, 62))
2014-08-15 23:33:16 +02:00
>(x: number) => 1 : (x: number) => number
2015-04-13 23:01:57 +02:00
>x : number, Symbol(x, Decl(subtypingWithCallSignatures.ts, 3, 18))
2015-04-13 21:36:11 +02:00
>1 : number
2014-08-15 23:33:16 +02:00
var r2 = foo1(<T>(x: T) => ''); // ok because base returns void
2015-04-13 23:01:57 +02:00
>r2 : (x: number) => void, Symbol(r2, Decl(subtypingWithCallSignatures.ts, 4, 7))
2014-08-15 23:33:16 +02:00
>foo1(<T>(x: T) => '') : (x: number) => void
2015-04-13 23:01:57 +02:00
>foo1 : { (cb: (x: number) => void): (x: number) => void; (cb: any): any; }, Symbol(foo1, Decl(subtypingWithCallSignatures.ts, 0, 22), Decl(subtypingWithCallSignatures.ts, 1, 62))
2014-08-15 23:33:16 +02:00
><T>(x: T) => '' : <T>(x: T) => string
2015-04-13 23:01:57 +02:00
>T : T, Symbol(T, Decl(subtypingWithCallSignatures.ts, 4, 19))
>x : T, Symbol(x, Decl(subtypingWithCallSignatures.ts, 4, 22))
>T : T, Symbol(T, Decl(subtypingWithCallSignatures.ts, 4, 19))
2015-04-13 21:36:11 +02:00
>'' : string
2014-08-15 23:33:16 +02:00
declare function foo2(cb: (x: number, y: number) => void): typeof cb;
2015-04-13 23:01:57 +02:00
>foo2 : { (cb: (x: number, y: number) => void): (x: number, y: number) => void; (cb: any): any; }, Symbol(foo2, Decl(subtypingWithCallSignatures.ts, 4, 35), Decl(subtypingWithCallSignatures.ts, 6, 73))
>cb : (x: number, y: number) => void, Symbol(cb, Decl(subtypingWithCallSignatures.ts, 6, 26))
>x : number, Symbol(x, Decl(subtypingWithCallSignatures.ts, 6, 31))
>y : number, Symbol(y, Decl(subtypingWithCallSignatures.ts, 6, 41))
>cb : (x: number, y: number) => void, Symbol(cb, Decl(subtypingWithCallSignatures.ts, 6, 26))
2014-08-15 23:33:16 +02:00
declare function foo2(cb: any): any;
2015-04-13 23:01:57 +02:00
>foo2 : { (cb: (x: number, y: number) => void): (x: number, y: number) => void; (cb: any): any; }, Symbol(foo2, Decl(subtypingWithCallSignatures.ts, 4, 35), Decl(subtypingWithCallSignatures.ts, 6, 73))
>cb : any, Symbol(cb, Decl(subtypingWithCallSignatures.ts, 7, 26))
2014-08-15 23:33:16 +02:00
var r3 = foo2((x: number, y: number) => 1); // ok because base returns void
2015-04-13 23:01:57 +02:00
>r3 : (x: number, y: number) => void, Symbol(r3, Decl(subtypingWithCallSignatures.ts, 8, 7))
2014-08-15 23:33:16 +02:00
>foo2((x: number, y: number) => 1) : (x: number, y: number) => void
2015-04-13 23:01:57 +02:00
>foo2 : { (cb: (x: number, y: number) => void): (x: number, y: number) => void; (cb: any): any; }, Symbol(foo2, Decl(subtypingWithCallSignatures.ts, 4, 35), Decl(subtypingWithCallSignatures.ts, 6, 73))
2014-08-15 23:33:16 +02:00
>(x: number, y: number) => 1 : (x: number, y: number) => number
2015-04-13 23:01:57 +02:00
>x : number, Symbol(x, Decl(subtypingWithCallSignatures.ts, 8, 19))
>y : number, Symbol(y, Decl(subtypingWithCallSignatures.ts, 8, 29))
2015-04-13 21:36:11 +02:00
>1 : number
2014-08-15 23:33:16 +02:00
var r4 = foo2(<T>(x: T) => ''); // ok because base returns void
2015-04-13 23:01:57 +02:00
>r4 : (x: number, y: number) => void, Symbol(r4, Decl(subtypingWithCallSignatures.ts, 9, 7))
2014-08-15 23:33:16 +02:00
>foo2(<T>(x: T) => '') : (x: number, y: number) => void
2015-04-13 23:01:57 +02:00
>foo2 : { (cb: (x: number, y: number) => void): (x: number, y: number) => void; (cb: any): any; }, Symbol(foo2, Decl(subtypingWithCallSignatures.ts, 4, 35), Decl(subtypingWithCallSignatures.ts, 6, 73))
2014-08-15 23:33:16 +02:00
><T>(x: T) => '' : <T>(x: T) => string
2015-04-13 23:01:57 +02:00
>T : T, Symbol(T, Decl(subtypingWithCallSignatures.ts, 9, 19))
>x : T, Symbol(x, Decl(subtypingWithCallSignatures.ts, 9, 22))
>T : T, Symbol(T, Decl(subtypingWithCallSignatures.ts, 9, 19))
2015-04-13 21:36:11 +02:00
>'' : string
2014-08-15 23:33:16 +02:00
}