36 lines
No EOL
1.2 KiB
Text
36 lines
No EOL
1.2 KiB
Text
==== tests/cases/compiler/implicitAnyWidenToAny.ts (4 errors) ====
|
|
// these should be errors
|
|
var x = null; // error at "x"
|
|
~
|
|
!!! Variable 'x' implicitly has an 'any' type.
|
|
var x1 = undefined; // error at "x1"
|
|
~~
|
|
!!! Variable 'x1' implicitly has an 'any' type.
|
|
var widenArray = [null, undefined]; // error at "widenArray"
|
|
~~~~~~~~~~
|
|
!!! Variable 'widenArray' implicitly has an 'any[]' type.
|
|
var emptyArray = []; // error at "emptyArray"
|
|
~~~~~~~~~~
|
|
!!! Variable 'emptyArray' implicitly has an 'any[]' type.
|
|
|
|
// 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];
|
|
var array5 = <any[]>[null, undefined];
|
|
|
|
var objLit: { new (n: number): any; };
|
|
function anyReturnFunc(): any { }
|
|
var obj0 = new objLit(1);
|
|
var obj1 = anyReturnFunc();
|
|
|