33 lines
1,019 B
Plaintext
33 lines
1,019 B
Plaintext
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts(25,21): error TS2532: Object is possibly 'undefined'.
|
|
|
|
|
|
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts (1 errors) ====
|
|
function foo1(results: number[] | undefined) {
|
|
(results ||= []).push(100);
|
|
}
|
|
|
|
function foo2(results: number[] | undefined) {
|
|
(results ??= []).push(100);
|
|
}
|
|
|
|
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);
|
|
~~~~~
|
|
!!! error TS2532: Object is possibly 'undefined'.
|
|
}
|
|
} |