TypeScript/tests/baselines/reference/logicalAssignment5(target=es2021).errors.txt

45 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

tests/cases/conformance/es2021/logicalAssignment/logicalAssignment5.ts(13,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
tests/cases/conformance/es2021/logicalAssignment/logicalAssignment5.ts(17,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/es2021/logicalAssignment/logicalAssignment5.ts(22,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/es2021/logicalAssignment/logicalAssignment5.ts(28,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
==== tests/cases/conformance/es2021/logicalAssignment/logicalAssignment5.ts (4 errors) ====
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)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
f(42)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}