TypeScript/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt
2014-07-12 17:30:19 -07:00

126 lines
3.5 KiB
Plaintext

==== tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts (24 errors) ====
var x: number;
x = 3; // OK
(x) = 3; // OK
x = ''; // Error
~
!!! Type 'string' is not assignable to type 'number'.
(x) = ''; // Error
~~~
!!! Type 'string' is not assignable to type 'number'.
module M {
export var y: number;
}
M.y = 3; // OK
(M).y = 3; // OK
(M.y) = 3; // OK
M.y = ''; // Error
~~~
!!! Type 'string' is not assignable to type 'number'.
(M).y = ''; // Error
~~~~~
!!! Type 'string' is not assignable to type 'number'.
(M.y) = ''; // Error
~~~~~
!!! Type 'string' is not assignable to type 'number'.
M = { y: 3 }; // Error
~
!!! Invalid left-hand side of assignment expression.
(M) = { y: 3 }; // Error
~~~
!!! Invalid left-hand side of assignment expression.
module M2 {
export module M3 {
export var x: number;
}
M3 = { x: 3 }; // Error
~~
!!! Invalid left-hand side of assignment expression.
}
M2.M3 = { x: 3 }; // OK
(M2).M3 = { x: 3 }; // OK
(M2.M3) = { x: 3 }; // OK
M2.M3 = { x: '' }; // Error
~~~~~
!!! Type '{ x: string; }' is not assignable to type 'typeof M3':
!!! Types of property 'x' are incompatible:
!!! Type 'string' is not assignable to type 'number'.
(M2).M3 = { x: '' }; // Error
~~~~~~~
!!! Type '{ x: string; }' is not assignable to type 'typeof M3':
!!! Types of property 'x' are incompatible:
!!! Type 'string' is not assignable to type 'number'.
(M2.M3) = { x: '' }; // Error
~~~~~~~
!!! Type '{ x: string; }' is not assignable to type 'typeof M3':
!!! Types of property 'x' are incompatible:
!!! Type 'string' is not assignable to type 'number'.
function fn() { }
fn = () => 3; // Bug 823548: Should be error (fn is not a reference)
~~
!!! Invalid left-hand side of assignment expression.
(fn) = () => 3; // Should be error
~~~~
!!! Invalid left-hand side of assignment expression.
function fn2(x: number, y: { t: number }) {
x = 3;
(x) = 3; // OK
x = ''; // Error
~
!!! Type 'string' is not assignable to type 'number'.
(x) = ''; // Error
~~~
!!! Type 'string' is not assignable to type 'number'.
(y).t = 3; // OK
(y.t) = 3; // OK
(y).t = ''; // Error
~~~~~
!!! Type 'string' is not assignable to type 'number'.
(y.t) = ''; // Error
~~~~~
!!! Type 'string' is not assignable to type 'number'.
y['t'] = 3; // OK
(y)['t'] = 3; // OK
(y['t']) = 3; // OK
y['t'] = ''; // Error
~~~~~~
!!! Type 'string' is not assignable to type 'number'.
(y)['t'] = ''; // Error
~~~~~~~~
!!! Type 'string' is not assignable to type 'number'.
(y['t']) = ''; // Error
~~~~~~~~
!!! Type 'string' is not assignable to type 'number'.
}
enum E {
A
}
E = undefined; // Error
~
!!! Invalid left-hand side of assignment expression.
(E) = undefined; // Error
~~~
!!! Invalid left-hand side of assignment expression.
class C {
}
C = undefined; // Error
~
!!! Invalid left-hand side of assignment expression.
(C) = undefined; // Error
~~~
!!! Invalid left-hand side of assignment expression.