TypeScript/tests/baselines/reference/functionImplementationErrors.errors.txt
Anders Hejlsberg 8199b0b236 Pull model for contextual types.
New baselines reflect a couple of unrelated bug fixes.
2014-07-29 18:21:16 -07:00

76 lines
2.4 KiB
Plaintext

==== tests/cases/conformance/functions/functionImplementationErrors.ts (8 errors) ====
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
var f1 = function () {
~~~~~~~~~~~~~
return '';
~~~~~~~~~~~~~~
return 3;
~~~~~~~~~~~~~
};
~
!!! No best common type exists among return expressions.
var f2 = function x() {
~~~~~~~~~~~~~~
return '';
~~~~~~~~~~~~~~
return 3;
~~~~~~~~~~~~~
};
~
!!! No best common type exists among return expressions.
var f3 = () => {
~~~~~~~
return '';
~~~~~~~~~~~~~~
return 3;
~~~~~~~~~~~~~
};
~
!!! No best common type exists among return expressions.
// FunctionExpression with no return type annotation with return branch of number[] and other of string[]
var f4 = function () {
~~~~~~~~~~~~~
if (true) {
~~~~~~~~~~~~~~~
return [''];
~~~~~~~~~~~~~~~~~~~~
} else {
~~~~~~~~~~~~
return [1];
~~~~~~~~~~~~~~~~~~~
}
~~~~~
}
~
!!! No best common type exists among return expressions.
// Function implemetnation with non -void return type annotation with no return
function f5(): number {
~~~~~~
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
}
var m;
// Function signature with parameter initializer referencing in scope local variable
function f6(n = m) {
~
!!! Initializer of parameter 'n' cannot reference identifier 'm' declared after it.
var m = 4;
}
// Function signature with initializer referencing other parameter to the right
function f7(n = m, m?) {
~
!!! Initializer of parameter 'n' cannot reference identifier 'm' declared after it.
}
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
// Should be error but isn't
undefined === function (): number {
~~~~~~
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
throw undefined;
var x = 4;
};