mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
logicalAssignment5.ts(13,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
|
|
logicalAssignment5.ts(17,12): error TS18048: 'f' is possibly 'undefined'.
|
|
logicalAssignment5.ts(22,12): error TS18048: 'f' is possibly 'undefined'.
|
|
logicalAssignment5.ts(28,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
|
|
|
|
|
|
==== 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 TS18048: 'f' is possibly 'undefined'.
|
|
f(42)
|
|
}
|
|
|
|
function bar2 (f?: (a: number) => void) {
|
|
f ||= (f.toString(), (a => a))
|
|
~
|
|
!!! error TS18048: 'f' 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'.
|
|
}
|
|
|