71 lines
3.7 KiB
Text
71 lines
3.7 KiB
Text
=== tests/cases/conformance/expressions/contextualTyping/objectLiteralContextualTyping.ts ===
|
|
// Tests related to #1774
|
|
|
|
interface Item {
|
|
>Item : Symbol(Item, Decl(objectLiteralContextualTyping.ts, 0, 0))
|
|
|
|
name: string;
|
|
>name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 2, 16))
|
|
|
|
description?: string;
|
|
>description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 3, 17))
|
|
}
|
|
|
|
declare function foo(item: Item): string;
|
|
>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41))
|
|
>item : Symbol(item, Decl(objectLiteralContextualTyping.ts, 7, 21))
|
|
>Item : Symbol(Item, Decl(objectLiteralContextualTyping.ts, 0, 0))
|
|
|
|
declare function foo(item: any): number;
|
|
>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41))
|
|
>item : Symbol(item, Decl(objectLiteralContextualTyping.ts, 8, 21))
|
|
|
|
var x = foo({ name: "Sprocket" });
|
|
>x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 10, 3), Decl(objectLiteralContextualTyping.ts, 11, 3))
|
|
>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41))
|
|
>name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 10, 13))
|
|
|
|
var x: string;
|
|
>x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 10, 3), Decl(objectLiteralContextualTyping.ts, 11, 3))
|
|
|
|
var y = foo({ name: "Sprocket", description: "Bumpy wheel" });
|
|
>y : Symbol(y, Decl(objectLiteralContextualTyping.ts, 13, 3), Decl(objectLiteralContextualTyping.ts, 14, 3))
|
|
>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41))
|
|
>name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 13, 13))
|
|
>description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 13, 31))
|
|
|
|
var y: string;
|
|
>y : Symbol(y, Decl(objectLiteralContextualTyping.ts, 13, 3), Decl(objectLiteralContextualTyping.ts, 14, 3))
|
|
|
|
var z = foo({ name: "Sprocket", description: false });
|
|
>z : Symbol(z, Decl(objectLiteralContextualTyping.ts, 16, 3), Decl(objectLiteralContextualTyping.ts, 17, 3))
|
|
>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41))
|
|
>name : Symbol(name, Decl(objectLiteralContextualTyping.ts, 16, 13))
|
|
>description : Symbol(description, Decl(objectLiteralContextualTyping.ts, 16, 31))
|
|
|
|
var z: number;
|
|
>z : Symbol(z, Decl(objectLiteralContextualTyping.ts, 16, 3), Decl(objectLiteralContextualTyping.ts, 17, 3))
|
|
|
|
var w = foo({ a: 10 });
|
|
>w : Symbol(w, Decl(objectLiteralContextualTyping.ts, 19, 3), Decl(objectLiteralContextualTyping.ts, 20, 3))
|
|
>foo : Symbol(foo, Decl(objectLiteralContextualTyping.ts, 5, 1), Decl(objectLiteralContextualTyping.ts, 7, 41))
|
|
>a : Symbol(a, Decl(objectLiteralContextualTyping.ts, 19, 13))
|
|
|
|
var w: number;
|
|
>w : Symbol(w, Decl(objectLiteralContextualTyping.ts, 19, 3), Decl(objectLiteralContextualTyping.ts, 20, 3))
|
|
|
|
declare function bar<T>(param: { x?: T }): T;
|
|
>bar : Symbol(bar, Decl(objectLiteralContextualTyping.ts, 20, 14))
|
|
>T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 22, 21))
|
|
>param : Symbol(param, Decl(objectLiteralContextualTyping.ts, 22, 24))
|
|
>x : Symbol(x, Decl(objectLiteralContextualTyping.ts, 22, 32))
|
|
>T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 22, 21))
|
|
>T : Symbol(T, Decl(objectLiteralContextualTyping.ts, 22, 21))
|
|
|
|
var b = bar({});
|
|
>b : Symbol(b, Decl(objectLiteralContextualTyping.ts, 24, 3), Decl(objectLiteralContextualTyping.ts, 25, 3))
|
|
>bar : Symbol(bar, Decl(objectLiteralContextualTyping.ts, 20, 14))
|
|
|
|
var b: {};
|
|
>b : Symbol(b, Decl(objectLiteralContextualTyping.ts, 24, 3), Decl(objectLiteralContextualTyping.ts, 25, 3))
|
|
|