mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
20 lines
624 B
Plaintext
20 lines
624 B
Plaintext
logicalAssignment8.ts(12,5): error TS2532: Object is possibly 'undefined'.
|
|
|
|
|
|
==== logicalAssignment8.ts (1 errors) ====
|
|
declare const bar: { value?: number[] } | undefined
|
|
|
|
function foo1(results: number[] | undefined) {
|
|
(results ||= bar?.value ?? []).push(100);
|
|
}
|
|
|
|
function foo2(results: number[] | undefined) {
|
|
(results ??= bar?.value ?? []).push(100);
|
|
}
|
|
|
|
function foo3(results: number[] | undefined) {
|
|
(results &&= bar?.value ?? []).push(100);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2532: Object is possibly 'undefined'.
|
|
}
|
|
|