2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts (5 errors) ====
|
|
|
|
// string can add every type, and result string cannot be assigned to below types
|
|
|
|
enum E { a, b, c }
|
|
|
|
|
|
|
|
var x1: boolean;
|
|
|
|
x1 += '';
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'boolean'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
var x2: number;
|
|
|
|
x2 += '';
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'number'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
var x3: E;
|
|
|
|
x3 += '';
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'E'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
var x4: {a: string};
|
|
|
|
x4 += '';
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2322: Type 'string' is not assignable to type '{ a: string; }':
|
|
|
|
!!! error TS2322: Property 'a' is missing in type 'String'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
var x5: void;
|
|
|
|
x5 += '';
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'void'.
|