2021-01-15 13:30:44 +03:00
|
|
|
// @strict: true
|
2022-02-04 11:08:38 +03:00
|
|
|
// @target: esnext, es2021, es2020, es2015
|
2021-01-15 13:30:44 +03:00
|
|
|
|
|
|
|
function foo1 (f?: (a: number) => void) {
|
|
|
|
f ??= (a => a)
|
|
|
|
f(42)
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo2 (f?: (a: number) => void) {
|
|
|
|
f ||= (a => a)
|
|
|
|
f(42)
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo3 (f?: (a: number) => void) {
|
|
|
|
f &&= (a => a)
|
|
|
|
f(42)
|
|
|
|
}
|
|
|
|
|
|
|
|
function bar1 (f?: (a: number) => void) {
|
|
|
|
f ??= (f.toString(), (a => a))
|
|
|
|
f(42)
|
|
|
|
}
|
|
|
|
|
|
|
|
function bar2 (f?: (a: number) => void) {
|
|
|
|
f ||= (f.toString(), (a => a))
|
|
|
|
f(42)
|
|
|
|
}
|
|
|
|
|
|
|
|
function bar3 (f?: (a: number) => void) {
|
|
|
|
f &&= (f.toString(), (a => a))
|
|
|
|
f(42)
|
|
|
|
}
|