2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts (11 errors) ====
|
|
|
|
var x = '';
|
|
|
|
|
|
|
|
var a: boolean = x;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'string' is not assignable to type 'boolean'.
|
|
|
|
var b: number = x;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'string' is not assignable to type 'number'.
|
|
|
|
var c: void = x;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'string' is not assignable to type 'void'.
|
|
|
|
var d: typeof undefined = x;
|
|
|
|
|
|
|
|
class C { foo: string; }
|
|
|
|
var e: C = x;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'string' is not assignable to type 'C':
|
|
|
|
!!! Property 'foo' is missing in type 'String'.
|
|
|
|
|
|
|
|
interface I { bar: string; }
|
|
|
|
var f: I = x;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'string' is not assignable to type 'I':
|
|
|
|
!!! Property 'bar' is missing in type 'String'.
|
|
|
|
|
|
|
|
var g: { baz: string } = 1;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'number' is not assignable to type '{ baz: string; }':
|
|
|
|
!!! Property 'baz' is missing in type 'Number'.
|
|
|
|
var g2: { 0: number } = 1;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'number' is not assignable to type '{ 0: number; }':
|
|
|
|
!!! Property '0' is missing in type 'Number'.
|
|
|
|
|
|
|
|
module M { export var x = 1; }
|
|
|
|
M = x;
|
|
|
|
~
|
|
|
|
!!! Invalid left-hand side of assignment expression.
|
|
|
|
|
|
|
|
function i<T>(a: T) {
|
|
|
|
a = x;
|
|
|
|
~
|
|
|
|
!!! Type 'string' is not assignable to type 'T'.
|
|
|
|
}
|
|
|
|
i = x;
|
|
|
|
~
|
|
|
|
!!! Invalid left-hand side of assignment expression.
|
|
|
|
|
|
|
|
enum E { A }
|
|
|
|
var j: E = x;
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'string' is not assignable to type 'E'.
|