2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/inferentialTypingWithFunctionTypeSyntacticScenarios.ts ===
|
|
|
|
declare function map<T, U>(array: T, func: (x: T) => U): U;
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
2014-08-15 23:33:16 +02:00
|
|
|
>T : T
|
|
|
|
>U : U
|
|
|
|
>array : T
|
|
|
|
>T : T
|
|
|
|
>func : (x: T) => U
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>U : U
|
|
|
|
>U : U
|
|
|
|
|
|
|
|
declare function identity<V>(y: V): V;
|
2014-08-28 21:52:44 +02:00
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
>V : V
|
|
|
|
>y : V
|
|
|
|
>V : V
|
|
|
|
>V : V
|
|
|
|
|
|
|
|
var s: string;
|
|
|
|
>s : string
|
|
|
|
|
|
|
|
// dotted name
|
|
|
|
var dottedIdentity = { x: identity };
|
2014-08-28 21:52:44 +02:00
|
|
|
>dottedIdentity : { x: <V>(y: V) => V; }
|
|
|
|
>{ x: identity } : { x: <V>(y: V) => V; }
|
|
|
|
>x : <V>(y: V) => V
|
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
s = map("", dottedIdentity.x);
|
|
|
|
>s = map("", dottedIdentity.x) : string
|
|
|
|
>s : string
|
|
|
|
>map("", dottedIdentity.x) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
>dottedIdentity.x : <V>(y: V) => V
|
|
|
|
>dottedIdentity : { x: <V>(y: V) => V; }
|
|
|
|
>x : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// index expression
|
|
|
|
s = map("", dottedIdentity['x']);
|
|
|
|
>s = map("", dottedIdentity['x']) : string
|
|
|
|
>s : string
|
|
|
|
>map("", dottedIdentity['x']) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
>dottedIdentity['x'] : <V>(y: V) => V
|
|
|
|
>dottedIdentity : { x: <V>(y: V) => V; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// function call
|
|
|
|
s = map("", (() => identity)());
|
|
|
|
>s = map("", (() => identity)()) : string
|
|
|
|
>s : string
|
|
|
|
>map("", (() => identity)()) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
>(() => identity)() : <V>(y: V) => V
|
|
|
|
>(() => identity) : () => <V>(y: V) => V
|
|
|
|
>() => identity : () => <V>(y: V) => V
|
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// construct
|
|
|
|
interface IdentityConstructor {
|
|
|
|
>IdentityConstructor : IdentityConstructor
|
|
|
|
|
|
|
|
new (): typeof identity;
|
2014-08-28 21:52:44 +02:00
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
var ic: IdentityConstructor;
|
|
|
|
>ic : IdentityConstructor
|
|
|
|
>IdentityConstructor : IdentityConstructor
|
|
|
|
|
|
|
|
s = map("", new ic());
|
|
|
|
>s = map("", new ic()) : string
|
|
|
|
>s : string
|
|
|
|
>map("", new ic()) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
>new ic() : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
>ic : IdentityConstructor
|
|
|
|
|
|
|
|
// assignment
|
|
|
|
var t;
|
|
|
|
>t : any
|
|
|
|
|
|
|
|
s = map("", t = identity);
|
|
|
|
>s = map("", t = identity) : string
|
|
|
|
>s : string
|
|
|
|
>map("", t = identity) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
>t = identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
>t : any
|
2014-08-28 21:52:44 +02:00
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// type assertion
|
|
|
|
s = map("", <typeof identity>identity);
|
|
|
|
>s = map("", <typeof identity>identity) : string
|
|
|
|
>s : string
|
|
|
|
>map("", <typeof identity>identity) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
><typeof identity>identity : <V>(y: V) => V
|
|
|
|
>identity : <V>(y: V) => V
|
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// parenthesized expression
|
|
|
|
s = map("", (identity));
|
|
|
|
>s = map("", (identity)) : string
|
|
|
|
>s : string
|
|
|
|
>map("", (identity)) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
>(identity) : <V>(y: V) => V
|
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// comma
|
|
|
|
s = map("", ("", identity));
|
|
|
|
>s = map("", ("", identity)) : string
|
|
|
|
>s : string
|
|
|
|
>map("", ("", identity)) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>map : <T, U>(array: T, func: (x: T) => U) => U
|
|
|
|
>("", identity) : <V>(y: V) => V
|
|
|
|
>"", identity : <V>(y: V) => V
|
|
|
|
>identity : <V>(y: V) => V
|
2014-08-15 23:33:16 +02:00
|
|
|
|