TypeScript/tests/baselines/reference/logicalAssignment4(target=es2015).errors.txt
2020-05-16 08:09:38 +08:00

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'.
}
}