TypeScript/tests/baselines/reference/widenedTypes.errors.txt

44 lines
1.7 KiB
Plaintext

==== tests/cases/compiler/widenedTypes.ts (8 errors) ====
null instanceof (() => { });
~~~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
({}) instanceof null; // Ok because null is a subtype of function
null in {};
~~~~
!!! The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.
"" in null;
~~~~
!!! The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter
for (var a in null) { }
~~~~
!!! The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
var t = [3, (3, null)];
t[3] = "";
~~~~
!!! Type 'string' is not assignable to type 'number'.
var x: typeof undefined = 3;
x = 3;
var y;
var u = [3, (y = null)];
u[3] = "";
~~~~
!!! Type 'string' is not assignable to type 'number'.
var ob: { x: typeof undefined } = { x: "" };
// Highlights the difference between array literals and object literals
var arr: string[] = [3, null]; // not assignable because null is not widened. BCT is {}
~~~
!!! Type 'number[]' is not assignable to type 'string[]':
!!! Type 'number' is not assignable to type 'string'.
var obj: { [x: string]: string; } = { x: 3, y: null }; // assignable because null is widened, and therefore BCT is any
~~~
!!! Type '{ [x: string]: number; x: number; y: null; }' is not assignable to type '{ [x: string]: string; }':
!!! Index signatures are incompatible:
!!! Type 'number' is not assignable to type 'string'.