1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
=== tests/cases/compiler/functionLikeInParameterInitializer.ts ===
// error
export function bar(func = () => foo) {
>bar : (func?: () => string) => void
>func : () => string
>() => foo : () => string
>foo : string
let foo = "in";
>foo : string
>"in" : "in"
}
// error
export function baz1(func = { f() { return foo } }) {
>baz1 : (func?: { f(): string; }) => void
>func : { f(): string; }
>{ f() { return foo } } : { f(): string; }
>f : () => string
>foo : string
let foo = "in";
>foo : string
>"in" : "in"
}
// error
export function baz2(func = function () { return foo }) {
>baz2 : (func?: () => string) => void
>func : () => string
>function () { return foo } : () => string
>foo : string
let foo = "in";
>foo : string
>"in" : "in"
}
// error
export function baz3(func = class { x = foo }) {
>baz3 : (func?: typeof (Anonymous class)) => void
>func : typeof (Anonymous class)
>class { x = foo } : typeof (Anonymous class)
>x : string
>foo : string
let foo = "in";
>foo : string
>"in" : "in"
}
|