2014-11-15 00:44:06 +01:00
|
|
|
//// [objectLiteralShorthandPropertiesAssignmentES6.ts]
|
|
|
|
var id: number = 10000;
|
|
|
|
var name: string = "my name";
|
|
|
|
|
|
|
|
var person: { name: string; id: number } = { name, id };
|
|
|
|
function foo(obj: { name: string }): void { };
|
|
|
|
function bar(name: string, id: number) { return { name, id }; }
|
|
|
|
function bar1(name: string, id: number) { return { name }; }
|
|
|
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
|
|
|
|
|
|
|
foo(person);
|
|
|
|
var person1 = bar("Hello", 5);
|
|
|
|
var person2: { name: string } = bar("Hello", 5);
|
|
|
|
var person3: { name: string; id: number } = bar("Hello", 5);
|
|
|
|
|
|
|
|
|
|
|
|
//// [objectLiteralShorthandPropertiesAssignmentES6.js]
|
|
|
|
var id = 10000;
|
|
|
|
var name = "my name";
|
|
|
|
var person = { name, id };
|
2015-02-07 03:45:09 +01:00
|
|
|
function foo(obj) { }
|
2014-11-15 00:44:06 +01:00
|
|
|
;
|
2015-02-07 05:03:24 +01:00
|
|
|
function bar(name, id) { return { name, id }; }
|
|
|
|
function bar1(name, id) { return { name }; }
|
|
|
|
function baz(name, id) { return { name, id }; }
|
2014-11-15 00:44:06 +01:00
|
|
|
foo(person);
|
|
|
|
var person1 = bar("Hello", 5);
|
|
|
|
var person2 = bar("Hello", 5);
|
|
|
|
var person3 = bar("Hello", 5);
|