2015-01-09 01:39:47 +01:00
|
|
|
=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts ===
|
|
|
|
|
|
|
|
function fun<T>(g: (x: T) => T, x: T): T;
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
|
|
|
>T : T
|
|
|
|
>g : (x: T) => T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
function fun<T>(g: (x: T) => T, h: (y: T) => T, x: T): T;
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
|
|
|
>T : T
|
|
|
|
>g : (x: T) => T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>h : (y: T) => T
|
|
|
|
>y : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
function fun<T>(g: (x: T) => T, x: T): T {
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
|
|
|
>T : T
|
|
|
|
>g : (x: T) => T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
return g(x);
|
|
|
|
>g(x) : T
|
|
|
|
>g : (x: T) => T
|
|
|
|
>x : T
|
|
|
|
}
|
|
|
|
|
|
|
|
var a = fun(x => x, 10);
|
|
|
|
>a : number
|
|
|
|
>fun(x => x, 10) : number
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
var b = fun((x => x), 10);
|
2015-01-10 00:10:32 +01:00
|
|
|
>b : number
|
|
|
|
>fun((x => x), 10) : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
var c = fun(((x => x)), 10);
|
2015-01-10 00:10:32 +01:00
|
|
|
>c : number
|
|
|
|
>fun(((x => x)), 10) : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>((x => x)) : (x: number) => number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
var d = fun((((x => x))), 10);
|
2015-01-10 00:10:32 +01:00
|
|
|
>d : number
|
|
|
|
>fun((((x => x))), 10) : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>(((x => x))) : (x: number) => number
|
|
|
|
>((x => x)) : (x: number) => number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
var e = fun(x => x, x => x, 10);
|
|
|
|
>e : number
|
|
|
|
>fun(x => x, x => x, 10) : number
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
var f = fun((x => x), (x => x), 10);
|
2015-01-10 00:10:32 +01:00
|
|
|
>f : number
|
|
|
|
>fun((x => x), (x => x), 10) : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
var g = fun(((x => x)), ((x => x)), 10);
|
2015-01-10 00:10:32 +01:00
|
|
|
>g : number
|
|
|
|
>fun(((x => x)), ((x => x)), 10) : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>((x => x)) : (x: number) => number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>((x => x)) : (x: number) => number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
var h = fun((((x => x))), ((x => x)), 10);
|
2015-01-10 00:10:32 +01:00
|
|
|
>h : number
|
|
|
|
>fun((((x => x))), ((x => x)), 10) : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>(((x => x))) : (x: number) => number
|
|
|
|
>((x => x)) : (x: number) => number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>((x => x)) : (x: number) => number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
// Ternaries in parens
|
|
|
|
var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10);
|
|
|
|
>i : any
|
|
|
|
>fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : any
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any
|
|
|
|
>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any
|
2015-01-09 01:39:47 +01:00
|
|
|
>Math.random() < 0.5 : boolean
|
|
|
|
>Math.random() : number
|
|
|
|
>Math.random : () => number
|
|
|
|
>Math : Math
|
|
|
|
>random : () => number
|
2015-01-10 00:10:32 +01:00
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>x => undefined : (x: number) => any
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>undefined : undefined
|
|
|
|
|
|
|
|
var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10);
|
|
|
|
>j : any
|
|
|
|
>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : any
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any
|
|
|
|
>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any
|
2015-01-09 01:39:47 +01:00
|
|
|
>Math.random() < 0.5 : boolean
|
|
|
|
>Math.random() : number
|
|
|
|
>Math.random : () => number
|
|
|
|
>Math : Math
|
|
|
|
>random : () => number
|
2015-01-10 00:10:32 +01:00
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>(x => undefined) : (x: number) => any
|
|
|
|
>x => undefined : (x: number) => any
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>undefined : undefined
|
|
|
|
|
|
|
|
var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10);
|
|
|
|
>k : any
|
|
|
|
>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : any
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any
|
|
|
|
>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any
|
2015-01-09 01:39:47 +01:00
|
|
|
>Math.random() < 0.5 : boolean
|
|
|
|
>Math.random() : number
|
|
|
|
>Math.random : () => number
|
|
|
|
>Math : Math
|
|
|
|
>random : () => number
|
2015-01-10 00:10:32 +01:00
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>(x => undefined) : (x: number) => any
|
|
|
|
>x => undefined : (x: number) => any
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>undefined : undefined
|
|
|
|
>x => x : (x: any) => any
|
|
|
|
>x : any
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10);
|
|
|
|
>l : any
|
|
|
|
>fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : any
|
|
|
|
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any
|
|
|
|
>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any
|
|
|
|
>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any
|
2015-01-09 01:39:47 +01:00
|
|
|
>Math.random() < 0.5 : boolean
|
|
|
|
>Math.random() : number
|
|
|
|
>Math.random : () => number
|
|
|
|
>Math : Math
|
|
|
|
>random : () => number
|
2015-01-10 00:10:32 +01:00
|
|
|
>((x => x)) : (x: number) => number
|
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
>((x => undefined)) : (x: number) => any
|
|
|
|
>(x => undefined) : (x: number) => any
|
|
|
|
>x => undefined : (x: number) => any
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>undefined : undefined
|
2015-01-30 06:22:56 +01:00
|
|
|
>((x => x)) : (x: any) => any
|
|
|
|
>(x => x) : (x: any) => any
|
|
|
|
>x => x : (x: any) => any
|
|
|
|
>x : any
|
|
|
|
>x : any
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
var lambda1: (x: number) => number = x => x;
|
|
|
|
>lambda1 : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
var lambda2: (x: number) => number = (x => x);
|
|
|
|
>lambda2 : (x: number) => number
|
|
|
|
>x : number
|
2015-01-10 00:10:32 +01:00
|
|
|
>(x => x) : (x: number) => number
|
|
|
|
>x => x : (x: number) => number
|
|
|
|
>x : number
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
|
|
|
|
type ObjType = { x: (p: number) => string; y: (p: string) => number };
|
|
|
|
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
|
|
|
>x : (p: number) => string
|
|
|
|
>p : number
|
|
|
|
>y : (p: string) => number
|
|
|
|
>p : string
|
|
|
|
|
|
|
|
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
|
|
|
|
>obj1 : { x: (p: number) => string; y: (p: string) => number; }
|
|
|
|
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
|
|
|
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
|
|
|
|
>x : (x: number) => any
|
|
|
|
>x => (x, undefined) : (x: number) => any
|
|
|
|
>x : number
|
|
|
|
>(x, undefined) : undefined
|
|
|
|
>x, undefined : undefined
|
|
|
|
>x : number
|
|
|
|
>undefined : undefined
|
|
|
|
>y : (y: string) => any
|
|
|
|
>y => (y, undefined) : (y: string) => any
|
|
|
|
>y : string
|
|
|
|
>(y, undefined) : undefined
|
|
|
|
>y, undefined : undefined
|
|
|
|
>y : string
|
|
|
|
>undefined : undefined
|
|
|
|
|
|
|
|
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
|
|
|
|
>obj2 : { x: (p: number) => string; y: (p: string) => number; }
|
|
|
|
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
2015-01-10 00:10:32 +01:00
|
|
|
>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; }
|
|
|
|
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
|
|
|
|
>x : (x: number) => any
|
|
|
|
>x => (x, undefined) : (x: number) => any
|
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>(x, undefined) : undefined
|
|
|
|
>x, undefined : undefined
|
2015-01-10 00:10:32 +01:00
|
|
|
>x : number
|
2015-01-09 01:39:47 +01:00
|
|
|
>undefined : undefined
|
2015-01-10 00:10:32 +01:00
|
|
|
>y : (y: string) => any
|
|
|
|
>y => (y, undefined) : (y: string) => any
|
|
|
|
>y : string
|
2015-01-09 01:39:47 +01:00
|
|
|
>(y, undefined) : undefined
|
|
|
|
>y, undefined : undefined
|
2015-01-10 00:10:32 +01:00
|
|
|
>y : string
|
2015-01-09 01:39:47 +01:00
|
|
|
>undefined : undefined
|
|
|
|
|