41 lines
No EOL
3.2 KiB
Text
41 lines
No EOL
3.2 KiB
Text
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
|
Property 'b' is missing in type '{ name: string; id: number; }'.
|
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected.
|
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,25): error TS1128: Declaration or statement expected.
|
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
|
Types of property 'id' are incompatible.
|
|
Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'.
|
|
Types of property 'id' are incompatible.
|
|
Type 'number' is not assignable to type 'boolean'.
|
|
|
|
|
|
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (6 errors) ====
|
|
var id: number = 10000;
|
|
var name: string = "my name";
|
|
|
|
var person: { b: string; id: number } = { name, id }; // error
|
|
~~~~~~
|
|
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
|
!!! error TS2322: Property 'b' is missing in type '{ name: string; id: number; }'.
|
|
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
|
~~~~
|
|
!!! error TS1131: Property or signature expected.
|
|
~~
|
|
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
|
~
|
|
!!! error TS1128: Declaration or statement expected.
|
|
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
|
!!! error TS2322: Types of property 'id' are incompatible.
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
function bar(obj: { name: string; id: boolean }) { }
|
|
bar({ name, id }); // error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'.
|
|
!!! error TS2345: Types of property 'id' are incompatible.
|
|
!!! error TS2345: Type 'number' is not assignable to type 'boolean'.
|
|
|
|
|