2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/typeArgInferenceWithNull.ts ===
|
|
|
|
// All legal
|
|
|
|
|
|
|
|
function fn4<T extends string>(n: T) { }
|
|
|
|
>fn4 : <T extends string>(n: T) => void
|
|
|
|
>T : T
|
|
|
|
>n : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
fn4(null);
|
|
|
|
>fn4(null) : void
|
|
|
|
>fn4 : <T extends string>(n: T) => void
|
|
|
|
|
|
|
|
function fn5<T extends { x: string }>(n: T) { }
|
|
|
|
>fn5 : <T extends { x: string; }>(n: T) => void
|
|
|
|
>T : T
|
|
|
|
>x : string
|
|
|
|
>n : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
fn5({ x: null });
|
|
|
|
>fn5({ x: null }) : void
|
|
|
|
>fn5 : <T extends { x: string; }>(n: T) => void
|
|
|
|
>{ x: null } : { x: null; }
|
2014-09-10 21:58:30 +02:00
|
|
|
>x : null
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function fn6<T extends { x: string }>(n: T, fun: (x: T) => void, n2: T) { }
|
|
|
|
>fn6 : <T extends { x: string; }>(n: T, fun: (x: T) => void, n2: T) => void
|
|
|
|
>T : T
|
|
|
|
>x : string
|
|
|
|
>n : T
|
|
|
|
>T : T
|
|
|
|
>fun : (x: T) => void
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>n2 : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
fn6({ x: null }, y => { }, { x: "" }); // y has type { x: any }, but ideally would have type { x: string }
|
|
|
|
>fn6({ x: null }, y => { }, { x: "" }) : void
|
|
|
|
>fn6 : <T extends { x: string; }>(n: T, fun: (x: T) => void, n2: T) => void
|
|
|
|
>{ x: null } : { x: null; }
|
2014-09-10 21:58:30 +02:00
|
|
|
>x : null
|
2014-08-15 23:33:16 +02:00
|
|
|
>y => { } : (y: { x: string; }) => void
|
|
|
|
>y : { x: string; }
|
|
|
|
>{ x: "" } : { x: string; }
|
|
|
|
>x : string
|
|
|
|
|