mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Adding regression test
This commit is contained in:
parent
f661508bb6
commit
963de957cb
29
tests/baselines/reference/objectLiteralContextualTyping.js
Normal file
29
tests/baselines/reference/objectLiteralContextualTyping.js
Normal 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;
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
Loading…
x
Reference in New Issue
Block a user