2014-11-11 20:31:45 +01:00
|
|
|
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment.ts ===
|
|
|
|
var id: number = 10000;
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
var name: string = "my name";
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
var person: { name: string; id: number } = { name, id };
|
|
|
|
>person : { name: string; id: number; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
>{ name, id } : { name: string; id: number; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
|
2014-11-15 00:44:06 +01:00
|
|
|
function foo( obj:{ name: string }): void { };
|
|
|
|
>foo : (obj: { name: string; }) => void
|
|
|
|
>obj : { name: string; }
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
function bar(name: string, id: number) { return { name, id }; }
|
|
|
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
>{ name, id } : { name: string; id: number; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
function bar1(name: string, id: number) { return { name }; }
|
|
|
|
>bar1 : (name: string, id: number) => { name: string; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
>{ name } : { name: string; }
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
|
|
|
>baz : (name: string, id: number) => { name: string; id: number; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
>{ name, id } : { name: string; id: number; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
foo(person);
|
|
|
|
>foo(person) : void
|
|
|
|
>foo : (obj: { name: string; }) => void
|
|
|
|
>person : { name: string; id: number; }
|
|
|
|
|
|
|
|
var person1 = bar("Hello", 5);
|
|
|
|
>person1 : { name: string; id: number; }
|
|
|
|
>bar("Hello", 5) : { name: string; id: number; }
|
|
|
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
|
|
|
|
|
|
|
var person2: { name: string } = bar("Hello", 5);
|
|
|
|
>person2 : { name: string; }
|
|
|
|
>name : string
|
|
|
|
>bar("Hello", 5) : { name: string; id: number; }
|
|
|
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
|
|
|
|
|
|
|
var person3: { name: string; id:number } = bar("Hello", 5);
|
|
|
|
>person3 : { name: string; id: number; }
|
|
|
|
>name : string
|
|
|
|
>id : number
|
|
|
|
>bar("Hello", 5) : { name: string; id: number; }
|
|
|
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
|
|
|
|