74 lines
No EOL
4.1 KiB
Text
74 lines
No EOL
4.1 KiB
Text
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(6,20): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,28): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(17,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(23,25): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(32,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(33,16): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,14): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,21): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
|
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,28): error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it.
|
|
|
|
|
|
==== tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts (10 errors) ====
|
|
function left(a, b = a, c = b) {
|
|
a;
|
|
b;
|
|
}
|
|
|
|
function right(a = b, b = a) {
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
a;
|
|
b;
|
|
}
|
|
|
|
function right2(a = b, b = c, c = a) {
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
|
a;
|
|
b;
|
|
c;
|
|
}
|
|
|
|
function inside(a = b) {
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
var b;
|
|
}
|
|
|
|
function outside() {
|
|
var b;
|
|
function inside(a = b) { // Still an error because b is declared inside the function
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
var b;
|
|
}
|
|
}
|
|
|
|
function defaultArgFunction(a = function () { return b; }, b = 1) { }
|
|
function defaultArgArrow(a = () => () => b, b = 3) { }
|
|
|
|
class C {
|
|
constructor(a = b, b = 1) { }
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
method(a = b, b = 1) { }
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
}
|
|
|
|
// Function expressions
|
|
var x = (a = b, b = c, c = d) => { var d; };
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
|
~
|
|
!!! error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it.
|
|
|
|
// Should not produce errors - can reference later parameters if they occur within a function expression initializer.
|
|
function f(a, b = function () { return c; }, c = b()) {
|
|
} |