2015-02-03 00:30:33 +01:00
|
|
|
//// [objectLiteralShorthandPropertiesAssignmentError.ts]
|
|
|
|
var id: number = 10000;
|
|
|
|
var name: string = "my name";
|
|
|
|
|
|
|
|
var person: { b: string; id: number } = { name, id }; // error
|
|
|
|
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
|
|
|
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
|
|
|
function bar(obj: { name: string; id: boolean }) { }
|
|
|
|
bar({ name, id }); // error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// [objectLiteralShorthandPropertiesAssignmentError.js]
|
|
|
|
var id = 10000;
|
|
|
|
var name = "my name";
|
|
|
|
var person = { name: name, id: id }; // error
|
|
|
|
var person1 = name, id;
|
|
|
|
; // error: can't use short-hand property assignment in type position
|
2015-02-07 05:03:24 +01:00
|
|
|
function foo(name, id) { return { name: name, id: id }; } // error
|
2015-02-07 03:45:09 +01:00
|
|
|
function bar(obj) { }
|
2015-02-03 00:30:33 +01:00
|
|
|
bar({ name: name, id: id }); // error
|