TypeScript/tests/baselines/reference/widenedTypes.errors.txt
2017-01-13 15:54:50 -08:00

60 lines
2.9 KiB
Plaintext

tests/cases/compiler/widenedTypes.ts(2,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/widenedTypes.ts(5,1): error TS2531: Object is possibly 'null'.
tests/cases/compiler/widenedTypes.ts(6,7): error TS2531: Object is possibly 'null'.
tests/cases/compiler/widenedTypes.ts(8,15): error TS2531: Object is possibly 'null'.
tests/cases/compiler/widenedTypes.ts(10,14): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/compiler/widenedTypes.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/compiler/widenedTypes.ts(18,1): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/compiler/widenedTypes.ts(23,5): error TS2322: Type 'number[]' is not assignable to type 'string[]'.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/widenedTypes.ts(24,5): error TS2322: Type '{ x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'.
Property 'x' is incompatible with index signature.
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/widenedTypes.ts (9 errors) ====
null instanceof (() => { });
~~~~
!!! error TS2358: 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 {};
~~~~
!!! error TS2531: Object is possibly 'null'.
"" in null;
~~~~
!!! error TS2531: Object is possibly 'null'.
for (var a in null) { }
~~~~
!!! error TS2531: Object is possibly 'null'.
var t = [3, (3, null)];
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
t[3] = "";
~~~~
!!! error TS2322: Type '""' is not assignable to type 'number'.
var x: typeof undefined = 3;
x = 3;
var y;
var u = [3, (y = null)];
u[3] = "";
~~~~
!!! error TS2322: Type '""' 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 {}
~~~
!!! error TS2322: Type 'number[]' is not assignable to type 'string[]'.
!!! error TS2322: 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
~~~
!!! error TS2322: Type '{ x: number; y: null; }' is not assignable to type '{ [x: string]: string; }'.
!!! error TS2322: Property 'x' is incompatible with index signature.
!!! error TS2322: Type 'number' is not assignable to type 'string'.