TypeScript/tests/baselines/reference/invalidStringAssignments.errors.txt
Hai Lin Zhang e44d39d4eb
Updated error message for TS2539 (#39827)
* Updated error message for TS2539

* Switch to multiple error messages

* inline variable

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-11 15:51:15 -08:00

64 lines
3.2 KiB
Plaintext

tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(3,5): error TS2322: Type 'string' is not assignable to type 'boolean'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(4,5): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(5,5): error TS2322: Type 'string' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(9,5): error TS2322: Type 'string' is not assignable to type 'C'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(12,5): error TS2322: Type 'string' is not assignable to type 'I'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(18,1): error TS2631: Cannot assign to 'M' because it is a namespace.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(23,1): error TS2630: Cannot assign to 'i' because it is a function.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5): error TS2322: Type 'string' is not assignable to type 'E'.
==== tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts (11 errors) ====
var x = '';
var a: boolean = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
var b: number = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var c: void = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'void'.
var d: typeof undefined = x;
class C { foo: string; }
var e: C = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'C'.
interface I { bar: string; }
var f: I = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'I'.
var g: { baz: string } = 1;
~
!!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
var g2: { 0: number } = 1;
~~
!!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
module M { export var x = 1; }
M = x;
~
!!! error TS2631: Cannot assign to 'M' because it is a namespace.
function i<T>(a: T) {
a = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.
}
i = x;
~
!!! error TS2630: Cannot assign to 'i' because it is a function.
enum E { A }
var j: E = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'E'.