62 lines
2.2 KiB
Plaintext
62 lines
2.2 KiB
Plaintext
|
==== tests/cases/compiler/defaultArgsForwardReferencing.ts (12 errors) ====
|
||
|
function left(a, b = a, c = b) {
|
||
|
a;
|
||
|
b;
|
||
|
}
|
||
|
|
||
|
function right(a = b, b = a) {
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
a;
|
||
|
b;
|
||
|
}
|
||
|
|
||
|
function right2(a = b, b = c, c = a) {
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
~
|
||
|
!!! Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||
|
a;
|
||
|
b;
|
||
|
c;
|
||
|
}
|
||
|
|
||
|
function inside(a = b) {
|
||
|
~
|
||
|
!!! 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
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
var b;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function defaultArgFunction(a = function () { return b; }, b = 1) { }
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
function defaultArgArrow(a = () => () => b, b = 3) { }
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
|
||
|
class C {
|
||
|
constructor(a = b, b = 1) { }
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
method(a = b, b = 1) { }
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
}
|
||
|
|
||
|
// Function expressions
|
||
|
var x = (a = b, b = c, c = d) => { var d; };
|
||
|
~
|
||
|
!!! Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||
|
~
|
||
|
!!! Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||
|
~
|
||
|
!!! Initializer of parameter 'c' cannot reference identifier 'd' declared after it.
|