mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
36 lines
1.3 KiB
Plaintext
36 lines
1.3 KiB
Plaintext
implicitAnyWidenToAny.ts(20,25): error TS2322: Type 'null' is not assignable to type 'number'.
|
|
implicitAnyWidenToAny.ts(20,31): error TS2322: Type 'undefined' is not assignable to type 'number'.
|
|
|
|
|
|
==== implicitAnyWidenToAny.ts (2 errors) ====
|
|
// these should be errors
|
|
var x = null; // error at "x"
|
|
var x1 = undefined; // error at "x1"
|
|
var widenArray = [null, undefined]; // error at "widenArray"
|
|
var emptyArray = [];
|
|
|
|
// these should not be error
|
|
class AnimalObj {
|
|
x:any;
|
|
}
|
|
var foo = 5;
|
|
var bar = "Hello World";
|
|
var foo1: any = null;
|
|
var foo2: any = undefined;
|
|
var temp: number = 5;
|
|
var c: AnimalObj = { x: null };
|
|
var array1 = ["Bob",2];
|
|
var array2: any[] = [];
|
|
var array3: any[] = [null, undefined];
|
|
var array4: number[] = [null, undefined];
|
|
~~~~
|
|
!!! error TS2322: Type 'null' is not assignable to type 'number'.
|
|
~~~~~~~~~
|
|
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
|
|
var array5 = <any[]>[null, undefined];
|
|
|
|
declare var objLit: { new (n: number): any; };
|
|
function anyReturnFunc(): any { }
|
|
var obj0 = new objLit(1);
|
|
var obj1 = anyReturnFunc();
|
|
|