2015-01-22 23:52:15 +01:00
|
|
|
=== tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts ===
|
2015-01-23 00:12:55 +01:00
|
|
|
// Tests related to #1774
|
2015-01-22 23:52:15 +01:00
|
|
|
|
|
|
|
interface Item {
|
|
|
|
>Item : Item
|
|
|
|
|
|
|
|
name: string;
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
description?: string;
|
|
|
|
>description : string
|
|
|
|
}
|
|
|
|
|
|
|
|
declare function foo(item: Item): string;
|
|
|
|
>foo : { (item: Item): string; (item: any): number; }
|
|
|
|
>item : Item
|
|
|
|
>Item : Item
|
|
|
|
|
|
|
|
declare function foo(item: any): number;
|
|
|
|
>foo : { (item: Item): string; (item: any): number; }
|
|
|
|
>item : any
|
|
|
|
|
|
|
|
var x = foo({ name: "Sprocket" });
|
|
|
|
>x : string
|
|
|
|
>foo({ name: "Sprocket" }) : string
|
|
|
|
>foo : { (item: Item): string; (item: any): number; }
|
2015-01-24 17:04:23 +01:00
|
|
|
>{ name: "Sprocket" } : { name: string; }
|
2015-01-22 23:52:15 +01:00
|
|
|
>name : string
|
|
|
|
|
|
|
|
var x: string;
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
var y = foo({ name: "Sprocket", description: "Bumpy wheel" });
|
|
|
|
>y : string
|
|
|
|
>foo({ name: "Sprocket", description: "Bumpy wheel" }) : string
|
|
|
|
>foo : { (item: Item): string; (item: any): number; }
|
|
|
|
>{ name: "Sprocket", description: "Bumpy wheel" } : { name: string; description: string; }
|
|
|
|
>name : string
|
|
|
|
>description : string
|
|
|
|
|
|
|
|
var y: string;
|
|
|
|
>y : string
|
|
|
|
|
2015-01-23 00:12:55 +01:00
|
|
|
var z = foo({ name: "Sprocket", description: false });
|
2015-01-22 23:52:15 +01:00
|
|
|
>z : number
|
2015-01-23 00:12:55 +01:00
|
|
|
>foo({ name: "Sprocket", description: false }) : number
|
|
|
|
>foo : { (item: Item): string; (item: any): number; }
|
|
|
|
>{ name: "Sprocket", description: false } : { name: string; description: boolean; }
|
|
|
|
>name : string
|
|
|
|
>description : boolean
|
|
|
|
|
|
|
|
var z: number;
|
|
|
|
>z : number
|
|
|
|
|
|
|
|
var w = foo({ a: 10 });
|
|
|
|
>w : number
|
2015-01-22 23:52:15 +01:00
|
|
|
>foo({ a: 10 }) : number
|
|
|
|
>foo : { (item: Item): string; (item: any): number; }
|
|
|
|
>{ a: 10 } : { a: number; }
|
|
|
|
>a : number
|
|
|
|
|
2015-01-23 00:12:55 +01:00
|
|
|
var w: number;
|
|
|
|
>w : number
|
|
|
|
|
|
|
|
declare function bar<T>(param: { x?: T }): T;
|
|
|
|
>bar : <T>(param: { x?: T; }) => T
|
|
|
|
>T : T
|
|
|
|
>param : { x?: T; }
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
var b = bar({});
|
|
|
|
>b : {}
|
|
|
|
>bar({}) : {}
|
|
|
|
>bar : <T>(param: { x?: T; }) => T
|
2015-01-24 17:04:23 +01:00
|
|
|
>{} : {}
|
2015-01-23 00:12:55 +01:00
|
|
|
|
|
|
|
var b: {};
|
|
|
|
>b : {}
|
2015-01-22 23:52:15 +01:00
|
|
|
|