2014-07-13 01:04:16 +02:00
|
|
|
//// [implicitAnyFunctionReturnNullOrUndefined.ts]
|
|
|
|
// this should be an error
|
|
|
|
function nullWidenFunction() { return null;} // error at "nullWidenFunction"
|
|
|
|
function undefinedWidenFunction() { return undefined; } // error at "undefinedWidenFunction"
|
|
|
|
|
|
|
|
class C {
|
|
|
|
nullWidenFuncOfC() { // error at "nullWidenFuncOfC"
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
underfinedWidenFuncOfC() { // error at "underfinedWidenFuncOfC"
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// this should not be an error
|
|
|
|
function foo1(): any { return null; }
|
|
|
|
function bar1(): any { return undefined; }
|
|
|
|
function fooBar(): number { return 1; }
|
|
|
|
function fooFoo() { return 5; }
|
|
|
|
|
|
|
|
// this should not be an error as the error is raised by expr above
|
|
|
|
nullWidenFunction();
|
|
|
|
undefinedWidenFunction();
|
|
|
|
|
|
|
|
|
|
|
|
//// [implicitAnyFunctionReturnNullOrUndefined.js]
|
2014-08-14 15:21:30 +02:00
|
|
|
// this should be an error
|
2014-07-13 01:04:16 +02:00
|
|
|
function nullWidenFunction() {
|
|
|
|
return null;
|
2014-08-15 22:18:54 +02:00
|
|
|
} // error at "nullWidenFunction"
|
2014-07-13 01:04:16 +02:00
|
|
|
function undefinedWidenFunction() {
|
|
|
|
return undefined;
|
2014-08-15 22:18:54 +02:00
|
|
|
} // error at "undefinedWidenFunction"
|
2014-07-13 01:04:16 +02:00
|
|
|
var C = (function () {
|
|
|
|
function C() {
|
|
|
|
}
|
|
|
|
C.prototype.nullWidenFuncOfC = function () {
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
C.prototype.underfinedWidenFuncOfC = function () {
|
|
|
|
return undefined;
|
|
|
|
};
|
|
|
|
return C;
|
|
|
|
})();
|
2014-08-14 15:21:30 +02:00
|
|
|
// this should not be an error
|
2014-07-13 01:04:16 +02:00
|
|
|
function foo1() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
function bar1() {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
function fooBar() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
function fooFoo() {
|
|
|
|
return 5;
|
|
|
|
}
|
2014-08-16 00:49:09 +02:00
|
|
|
// this should not be an error as the error is raised by expr above
|
2014-07-13 01:04:16 +02:00
|
|
|
nullWidenFunction();
|
|
|
|
undefinedWidenFunction();
|