2014-07-13 01:04:16 +02:00
|
|
|
//// [implicitAnyWidenToAny.ts]
|
|
|
|
// 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 = []; // error at "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];
|
|
|
|
var array5 = <any[]>[null, undefined];
|
|
|
|
|
|
|
|
var objLit: { new (n: number): any; };
|
|
|
|
function anyReturnFunc(): any { }
|
|
|
|
var obj0 = new objLit(1);
|
|
|
|
var obj1 = anyReturnFunc();
|
|
|
|
|
|
|
|
|
|
|
|
//// [implicitAnyWidenToAny.js]
|
2014-08-12 00:54:12 +02:00
|
|
|
// these should be errors
|
2014-08-15 22:18:54 +02:00
|
|
|
var x = null; // error at "x"
|
|
|
|
var x1 = undefined; // error at "x1"
|
|
|
|
var widenArray = [null, undefined]; // error at "widenArray"
|
|
|
|
var emptyArray = []; // error at "emptyArray"
|
2014-08-14 15:42:18 +02:00
|
|
|
// these should not be error
|
2014-07-13 01:04:16 +02:00
|
|
|
var AnimalObj = (function () {
|
|
|
|
function AnimalObj() {
|
|
|
|
}
|
|
|
|
return AnimalObj;
|
|
|
|
})();
|
|
|
|
var foo = 5;
|
|
|
|
var bar = "Hello World";
|
|
|
|
var foo1 = null;
|
|
|
|
var foo2 = undefined;
|
|
|
|
var temp = 5;
|
|
|
|
var c = { x: null };
|
|
|
|
var array1 = ["Bob", 2];
|
|
|
|
var array2 = [];
|
|
|
|
var array3 = [null, undefined];
|
|
|
|
var array4 = [null, undefined];
|
|
|
|
var array5 = [null, undefined];
|
|
|
|
var objLit;
|
2015-02-07 03:45:09 +01:00
|
|
|
function anyReturnFunc() { }
|
2014-07-13 01:04:16 +02:00
|
|
|
var obj0 = new objLit(1);
|
|
|
|
var obj1 = anyReturnFunc();
|