61 lines
1.6 KiB
Text
61 lines
1.6 KiB
Text
=== tests/cases/compiler/typeArgInference2.ts ===
|
|
interface Item {
|
|
>Item : Item
|
|
|
|
name: string;
|
|
>name : string
|
|
}
|
|
|
|
declare function foo<T extends Item>(x?: T, y?: T): T;
|
|
>foo : <T extends Item>(x?: T, y?: T) => T
|
|
>T : T
|
|
>Item : Item
|
|
>x : T
|
|
>T : T
|
|
>y : T
|
|
>T : T
|
|
>T : T
|
|
|
|
var z1 = foo(null); // any
|
|
>z1 : any
|
|
>foo(null) : any
|
|
>foo : <T extends Item>(x?: T, y?: T) => T
|
|
|
|
var z2 = foo(); // Item
|
|
>z2 : Item
|
|
>foo() : Item
|
|
>foo : <T extends Item>(x?: T, y?: T) => T
|
|
|
|
var z3 = foo({ name: null }); // { name: any }
|
|
>z3 : { name: any; }
|
|
>foo({ name: null }) : { name: any; }
|
|
>foo : <T extends Item>(x?: T, y?: T) => T
|
|
>{ name: null } : { name: null; }
|
|
>name : null
|
|
|
|
var z4 = foo({ name: "abc" }); // { name: string }
|
|
>z4 : { name: string; }
|
|
>foo({ name: "abc" }) : { name: string; }
|
|
>foo : <T extends Item>(x?: T, y?: T) => T
|
|
>{ name: "abc" } : { name: string; }
|
|
>name : string
|
|
|
|
var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number }
|
|
>z5 : { name: string; a: number; }
|
|
>foo({ name: "abc", a: 5 }) : { name: string; a: number; }
|
|
>foo : <T extends Item>(x?: T, y?: T) => T
|
|
>{ name: "abc", a: 5 } : { name: string; a: number; }
|
|
>name : string
|
|
>a : number
|
|
|
|
var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // Item
|
|
>z6 : Item
|
|
>foo({ name: "abc", a: 5 }, { name: "def", b: 5 }) : Item
|
|
>foo : <T extends Item>(x?: T, y?: T) => T
|
|
>{ name: "abc", a: 5 } : { name: string; a: number; }
|
|
>name : string
|
|
>a : number
|
|
>{ name: "def", b: 5 } : { name: string; b: number; }
|
|
>name : string
|
|
>b : number
|
|
|