Adding regression test

This commit is contained in:
Anders Hejlsberg 2015-01-22 14:52:15 -08:00
parent f661508bb6
commit 963de957cb
3 changed files with 100 additions and 0 deletions

View file

@ -0,0 +1,29 @@
//// [objectLiteralContextualTyping.ts]
// Test related to #1774
interface Item {
name: string;
description?: string;
}
declare function foo(item: Item): string;
declare function foo(item: any): number;
var x = foo({ name: "Sprocket" });
var x: string;
var y = foo({ name: "Sprocket", description: "Bumpy wheel" });
var y: string;
var z = foo({ a: 10 });
var z: number;
//// [objectLiteralContextualTyping.js]
// Test related to #1774
var x = foo({ name: "Sprocket" });
var x;
var y = foo({ name: "Sprocket", description: "Bumpy wheel" });
var y;
var z = foo({ a: 10 });
var z;

View file

@ -0,0 +1,53 @@
=== tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts ===
// Test related to #1774
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; }
>{ name: "Sprocket" } : { name: string; description?: string; }
>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
var z = foo({ a: 10 });
>z : number
>foo({ a: 10 }) : number
>foo : { (item: Item): string; (item: any): number; }
>{ a: 10 } : { a: number; }
>a : number
var z: number;
>z : number

View file

@ -0,0 +1,18 @@
// Test related to #1774
interface Item {
name: string;
description?: string;
}
declare function foo(item: Item): string;
declare function foo(item: any): number;
var x = foo({ name: "Sprocket" });
var x: string;
var y = foo({ name: "Sprocket", description: "Bumpy wheel" });
var y: string;
var z = foo({ a: 10 });
var z: number;