2020-04-01 05:37:58 +02:00
|
|
|
// @strict: true
|
|
|
|
// @target: esnext, es2020, es2015
|
2020-04-01 21:01:19 +02:00
|
|
|
// @allowUnreachableCode: false
|
2020-04-01 05:37:58 +02:00
|
|
|
|
|
|
|
function foo1(results: number[] | undefined) {
|
|
|
|
(results ||= []).push(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo2(results: number[] | undefined) {
|
|
|
|
(results ??= []).push(100);
|
2020-04-01 17:39:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function foo3(results: number[] | undefined) {
|
|
|
|
results ||= [];
|
|
|
|
results.push(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo4(results: number[] | undefined) {
|
|
|
|
results ||= [];
|
|
|
|
results.push(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ThingWithOriginal {
|
|
|
|
name: string;
|
|
|
|
original?: ThingWithOriginal
|
|
|
|
}
|
|
|
|
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
|
|
|
|
if (thing &&= thing.original) {
|
|
|
|
console.log(thing.name);
|
|
|
|
}
|
2020-04-01 05:37:58 +02:00
|
|
|
}
|