2018-08-09 10:40:11 +02:00
|
|
|
let foo: string = "";
|
|
|
|
|
|
|
|
function f1 (bar = foo) { // unexpected compiler error; works at runtime
|
|
|
|
var foo: number = 2;
|
|
|
|
return bar; // returns 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at runtime
|
|
|
|
var foo: number = 2;
|
|
|
|
return bar(); // returns 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime
|
|
|
|
return bar;
|
|
|
|
}
|
|
|
|
|
|
|
|
function f4 (foo, bar = foo) {
|
|
|
|
return bar
|
|
|
|
}
|
|
|
|
|
|
|
|
function f5 (a = a) {
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
|
|
|
function f6 (async = async) {
|
|
|
|
return async
|
2018-08-28 10:41:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function f7({[foo]: bar}: any[]) {
|
|
|
|
let foo: number = 2;
|
|
|
|
}
|
2018-08-29 15:58:55 +02:00
|
|
|
|
|
|
|
class Foo {
|
|
|
|
constructor(public x = 12, public y = x) {}
|
|
|
|
}
|
2018-08-30 17:48:49 +02:00
|
|
|
|
|
|
|
function f8(foo1: string, bar = foo1) { }
|