--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: nullishAndLogicalOr2.ts --- # Input ```ts (foo1?.foo2 ?? {}).#foo3; ((() => foo())() ?? {}).#bar; const foo = (bar ?? {}).#baz; (foo.bar ?? {})[baz]; ((foo1 ?? {}).#foo2 ?? {}).#foo3; (foo ?? undefined ?? {}).#bar; (foo() ?? bar ?? {}).#baz; ((foo1 ? foo2 : foo3) ?? {}).#foo4; if (foo) { (foo ?? {}).#bar; } if ((foo ?? {}).#bar) { foo.bar; } (undefined && foo ?? {}).#bar; (a > b || {}).#bar; (((typeof x) as string) || {}).#bar; (void foo() || {}).#bar; ((a ? b : c) || {}).#bar; ((a instanceof Error) || {}).#bar; ((a << b) || {}).#bar; ((foo ** 2) || {}).#bar; (foo ** 2 || {}).#bar; (foo++ || {}).#bar; (+foo || {}).#bar; //this expression (this || {}).bar; (this || ({})).bar; (await this || {}).bar; const foo = (this || {}).baz; ((this || {}).foo2 || {}).foo3; if (foo) { (this || {}).bar; } if ((this || {}).bar) { foo.bar; } (undefined && this || {}).bar; (this ?? {}).bar; (this ?? ({})).bar; (await this ?? {}).bar; const foo = (this ?? {}).baz; ((this ?? {}).foo2 ?? {}).foo3; if (foo) { (this ?? {}).bar; } if ((this ?? {}).bar) { foo.bar; } (undefined && this ?? {}).bar; (((typeof this) as string) || {}).bar; // this expression with private name (this || {}).#bar; (this || ({})).#bar; (await this || {}).#bar; const foo = (this || {}).#baz; ((this || {}).#foo2 || {}).#foo3; if (foo) { (this || {}).#bar; } if ((this || {}).#bar) { foo.bar; } (undefined && this || {}).#bar; (this ?? {}).#bar; (this ?? ({})).#bar; (await this ?? {}).#bar; const foo = (this ?? {}).#baz; ((this ?? {}).#foo2 ?? {}).#foo3; if (foo) { (this ?? {}).#bar; } if ((this ?? {}).#bar) { foo.bar; } (undefined && this ?? {}).#bar; (((typeof this) as string) || {}).#bar; // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 (foo() || {}).bar; ((foo || {}).bar() || {}).baz; ``` # Diagnostics ``` nullishAndLogicalOr2.ts:1:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. > 1 │ (foo1?.foo2 ?? {}).#foo3; │ ^^^^^^^^^^^^^^^^^^^^^^^^ 2 │ ((() => foo())() ?? {}).#bar; 3 │ const foo = (bar ?? {}).#baz; i Unsafe fix: Change to an optional chain. 1 │ (foo1?.foo2·??·{}).#foo3; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:2:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 1 │ (foo1?.foo2 ?? {}).#foo3; > 2 │ ((() => foo())() ?? {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 │ const foo = (bar ?? {}).#baz; 4 │ (foo.bar ?? {})[baz]; i Unsafe fix: Change to an optional chain. 2 │ ((()·=>·foo())()·??·{}).#bar; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:3:13 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 1 │ (foo1?.foo2 ?? {}).#foo3; 2 │ ((() => foo())() ?? {}).#bar; > 3 │ const foo = (bar ?? {}).#baz; │ ^^^^^^^^^^^^^^^^ 4 │ (foo.bar ?? {})[baz]; 5 │ ((foo1 ?? {}).#foo2 ?? {}).#foo3; i Unsafe fix: Change to an optional chain. 3 │ const·foo·=·(bar·??·{}).#baz; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:4:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 2 │ ((() => foo())() ?? {}).#bar; 3 │ const foo = (bar ?? {}).#baz; > 4 │ (foo.bar ?? {})[baz]; │ ^^^^^^^^^^^^^^^^^^^^ 5 │ ((foo1 ?? {}).#foo2 ?? {}).#foo3; 6 │ i Unsafe fix: Change to an optional chain. 2 2 │ ((() => foo())() ?? {}).#bar; 3 3 │ const foo = (bar ?? {}).#baz; 4 │ - (foo.bar·??·{})[baz]; 4 │ + foo.bar?.[baz]; 5 5 │ ((foo1 ?? {}).#foo2 ?? {}).#foo3; 6 6 │ ``` ``` nullishAndLogicalOr2.ts:5:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 3 │ const foo = (bar ?? {}).#baz; 4 │ (foo.bar ?? {})[baz]; > 5 │ ((foo1 ?? {}).#foo2 ?? {}).#foo3; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 │ 7 │ (foo ?? undefined ?? {}).#bar; i Unsafe fix: Change to an optional chain. 5 │ ((foo1·??·{}).#foo2·??·{}).#foo3; │ -- -- ---- - ----- ``` ``` nullishAndLogicalOr2.ts:7:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 5 │ ((foo1 ?? {}).#foo2 ?? {}).#foo3; 6 │ > 7 │ (foo ?? undefined ?? {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 │ (foo() ?? bar ?? {}).#baz; 9 │ ((foo1 ? foo2 : foo3) ?? {}).#foo4; i Unsafe fix: Change to an optional chain. 5 5 │ ((foo1 ?? {}).#foo2 ?? {}).#foo3; 6 6 │ 7 │ - (foo·??·undefined·??·{}).#bar; 7 │ + (foo·??·undefined)?.#bar; 8 8 │ (foo() ?? bar ?? {}).#baz; 9 9 │ ((foo1 ? foo2 : foo3) ?? {}).#foo4; ``` ``` nullishAndLogicalOr2.ts:8:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 7 │ (foo ?? undefined ?? {}).#bar; > 8 │ (foo() ?? bar ?? {}).#baz; │ ^^^^^^^^^^^^^^^^^^^^^^^^^ 9 │ ((foo1 ? foo2 : foo3) ?? {}).#foo4; 10 │ i Unsafe fix: Change to an optional chain. 6 6 │ 7 7 │ (foo ?? undefined ?? {}).#bar; 8 │ - (foo()·??·bar·??·{}).#baz; 8 │ + (foo()·??·bar)?.#baz; 9 9 │ ((foo1 ? foo2 : foo3) ?? {}).#foo4; 10 10 │ ``` ``` nullishAndLogicalOr2.ts:9:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 7 │ (foo ?? undefined ?? {}).#bar; 8 │ (foo() ?? bar ?? {}).#baz; > 9 │ ((foo1 ? foo2 : foo3) ?? {}).#foo4; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 │ 11 │ if (foo) { (foo ?? {}).#bar; } i Unsafe fix: Change to an optional chain. 9 │ ((foo1·?·foo2·:·foo3)·??·{}).#foo4; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:11:12 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 9 │ ((foo1 ? foo2 : foo3) ?? {}).#foo4; 10 │ > 11 │ if (foo) { (foo ?? {}).#bar; } │ ^^^^^^^^^^^^^^^^ 12 │ if ((foo ?? {}).#bar) { foo.bar; } 13 │ i Unsafe fix: Change to an optional chain. 11 │ if·(foo)·{·(foo·??·{}).#bar;·} │ - - ----- ``` ``` nullishAndLogicalOr2.ts:12:5 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 11 │ if (foo) { (foo ?? {}).#bar; } > 12 │ if ((foo ?? {}).#bar) { foo.bar; } │ ^^^^^^^^^^^^^^^^ 13 │ 14 │ (undefined && foo ?? {}).#bar; i Unsafe fix: Change to an optional chain. 12 │ if·((foo·??·{}).#bar)·{·foo.bar;·} │ - - ----- ``` ``` nullishAndLogicalOr2.ts:14:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 12 │ if ((foo ?? {}).#bar) { foo.bar; } 13 │ > 14 │ (undefined && foo ?? {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 │ (a > b || {}).#bar; 16 │ (((typeof x) as string) || {}).#bar; i Unsafe fix: Change to an optional chain. 12 12 │ if ((foo ?? {}).#bar) { foo.bar; } 13 13 │ 14 │ - (undefined·&&·foo·??·{}).#bar; 14 │ + (undefined·&&·foo)?.#bar; 15 15 │ (a > b || {}).#bar; 16 16 │ (((typeof x) as string) || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:15:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 14 │ (undefined && foo ?? {}).#bar; > 15 │ (a > b || {}).#bar; │ ^^^^^^^^^^^^^^^^^^ 16 │ (((typeof x) as string) || {}).#bar; 17 │ i Unsafe fix: Change to an optional chain. 13 13 │ 14 14 │ (undefined && foo ?? {}).#bar; 15 │ - (a·>·b·||·{}).#bar; 15 │ + (a·>·b)?.#bar; 16 16 │ (((typeof x) as string) || {}).#bar; 17 17 │ ``` ``` nullishAndLogicalOr2.ts:16:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 14 │ (undefined && foo ?? {}).#bar; 15 │ (a > b || {}).#bar; > 16 │ (((typeof x) as string) || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 │ 18 │ (void foo() || {}).#bar; i Unsafe fix: Change to an optional chain. 14 14 │ (undefined && foo ?? {}).#bar; 15 15 │ (a > b || {}).#bar; 16 │ - (((typeof·x)·as·string)·||·{}).#bar; 16 │ + ((typeof·x)·as·string)?.#bar; 17 17 │ 18 18 │ (void foo() || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:18:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 16 │ (((typeof x) as string) || {}).#bar; 17 │ > 18 │ (void foo() || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^ 19 │ ((a ? b : c) || {}).#bar; 20 │ i Unsafe fix: Change to an optional chain. 16 16 │ (((typeof x) as string) || {}).#bar; 17 17 │ 18 │ - (void·foo()·||·{}).#bar; 18 │ + (void·foo())?.#bar; 19 19 │ ((a ? b : c) || {}).#bar; 20 20 │ ``` ``` nullishAndLogicalOr2.ts:19:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 18 │ (void foo() || {}).#bar; > 19 │ ((a ? b : c) || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^ 20 │ 21 │ ((a instanceof Error) || {}).#bar; i Unsafe fix: Change to an optional chain. 17 17 │ 18 18 │ (void foo() || {}).#bar; 19 │ - ((a·?·b·:·c)·||·{}).#bar; 19 │ + (a·?·b·:·c)?.#bar; 20 20 │ 21 21 │ ((a instanceof Error) || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:21:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 19 │ ((a ? b : c) || {}).#bar; 20 │ > 21 │ ((a instanceof Error) || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 │ ((a << b) || {}).#bar; 23 │ ((foo ** 2) || {}).#bar; i Unsafe fix: Change to an optional chain. 19 19 │ ((a ? b : c) || {}).#bar; 20 20 │ 21 │ - ((a·instanceof·Error)·||·{}).#bar; 21 │ + (a·instanceof·Error)?.#bar; 22 22 │ ((a << b) || {}).#bar; 23 23 │ ((foo ** 2) || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:22:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 21 │ ((a instanceof Error) || {}).#bar; > 22 │ ((a << b) || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^ 23 │ ((foo ** 2) || {}).#bar; 24 │ (foo ** 2 || {}).#bar; i Unsafe fix: Change to an optional chain. 20 20 │ 21 21 │ ((a instanceof Error) || {}).#bar; 22 │ - ((a·<<·b)·||·{}).#bar; 22 │ + (a·<<·b)?.#bar; 23 23 │ ((foo ** 2) || {}).#bar; 24 24 │ (foo ** 2 || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:23:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 21 │ ((a instanceof Error) || {}).#bar; 22 │ ((a << b) || {}).#bar; > 23 │ ((foo ** 2) || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^ 24 │ (foo ** 2 || {}).#bar; 25 │ (foo++ || {}).#bar; i Unsafe fix: Change to an optional chain. 21 21 │ ((a instanceof Error) || {}).#bar; 22 22 │ ((a << b) || {}).#bar; 23 │ - ((foo·**·2)·||·{}).#bar; 23 │ + (foo·**·2)?.#bar; 24 24 │ (foo ** 2 || {}).#bar; 25 25 │ (foo++ || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:24:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 22 │ ((a << b) || {}).#bar; 23 │ ((foo ** 2) || {}).#bar; > 24 │ (foo ** 2 || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^ 25 │ (foo++ || {}).#bar; 26 │ (+foo || {}).#bar; i Unsafe fix: Change to an optional chain. 22 22 │ ((a << b) || {}).#bar; 23 23 │ ((foo ** 2) || {}).#bar; 24 │ - (foo·**·2·||·{}).#bar; 24 │ + (foo·**·2)?.#bar; 25 25 │ (foo++ || {}).#bar; 26 26 │ (+foo || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:25:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 23 │ ((foo ** 2) || {}).#bar; 24 │ (foo ** 2 || {}).#bar; > 25 │ (foo++ || {}).#bar; │ ^^^^^^^^^^^^^^^^^^ 26 │ (+foo || {}).#bar; 27 │ i Unsafe fix: Change to an optional chain. 23 23 │ ((foo ** 2) || {}).#bar; 24 24 │ (foo ** 2 || {}).#bar; 25 │ - (foo++·||·{}).#bar; 25 │ + (foo++)?.#bar; 26 26 │ (+foo || {}).#bar; 27 27 │ ``` ``` nullishAndLogicalOr2.ts:26:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 24 │ (foo ** 2 || {}).#bar; 25 │ (foo++ || {}).#bar; > 26 │ (+foo || {}).#bar; │ ^^^^^^^^^^^^^^^^^ 27 │ i Unsafe fix: Change to an optional chain. 24 24 │ (foo ** 2 || {}).#bar; 25 25 │ (foo++ || {}).#bar; 26 │ - (+foo·||·{}).#bar; 26 │ + (+foo)?.#bar; 27 27 │ 28 28 │ ``` ``` nullishAndLogicalOr2.ts:30:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 29 │ //this expression > 30 │ (this || {}).bar; │ ^^^^^^^^^^^^^^^^ 31 │ (this || ({})).bar; 32 │ (await this || {}).bar; i Unsafe fix: Change to an optional chain. 28 28 │ 29 29 │ //this expression 30 │ - (this·||·{}).bar; 30 │ + this?.bar; 31 31 │ (this || ({})).bar; 32 32 │ (await this || {}).bar; ``` ``` nullishAndLogicalOr2.ts:31:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 29 │ //this expression 30 │ (this || {}).bar; > 31 │ (this || ({})).bar; │ ^^^^^^^^^^^^^^^^^^ 32 │ (await this || {}).bar; 33 │ const foo = (this || {}).baz; i Unsafe fix: Change to an optional chain. 29 29 │ //this expression 30 30 │ (this || {}).bar; 31 │ - (this·||·({})).bar; 31 │ + this?.bar; 32 32 │ (await this || {}).bar; 33 33 │ const foo = (this || {}).baz; ``` ``` nullishAndLogicalOr2.ts:32:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 30 │ (this || {}).bar; 31 │ (this || ({})).bar; > 32 │ (await this || {}).bar; │ ^^^^^^^^^^^^^^^^^^^^^^ 33 │ const foo = (this || {}).baz; 34 │ i Unsafe fix: Change to an optional chain. 30 30 │ (this || {}).bar; 31 31 │ (this || ({})).bar; 32 │ - (await·this·||·{}).bar; 32 │ + (await·this)?.bar; 33 33 │ const foo = (this || {}).baz; 34 34 │ ``` ``` nullishAndLogicalOr2.ts:33:13 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 31 │ (this || ({})).bar; 32 │ (await this || {}).bar; > 33 │ const foo = (this || {}).baz; │ ^^^^^^^^^^^^^^^^ 34 │ 35 │ ((this || {}).foo2 || {}).foo3; i Unsafe fix: Change to an optional chain. 31 31 │ (this || ({})).bar; 32 32 │ (await this || {}).bar; 33 │ - const·foo·=·(this·||·{}).baz; 33 │ + const·foo·=·this?.baz; 34 34 │ 35 35 │ ((this || {}).foo2 || {}).foo3; ``` ``` nullishAndLogicalOr2.ts:35:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 33 │ const foo = (this || {}).baz; 34 │ > 35 │ ((this || {}).foo2 || {}).foo3; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 │ 37 │ if (foo) { (this || {}).bar; } i Unsafe fix: Change to an optional chain. 33 33 │ const foo = (this || {}).baz; 34 34 │ 35 │ - ((this·||·{}).foo2·||·{}).foo3; 35 │ + this?.foo2?.foo3; 36 36 │ 37 37 │ if (foo) { (this || {}).bar; } ``` ``` nullishAndLogicalOr2.ts:37:12 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 35 │ ((this || {}).foo2 || {}).foo3; 36 │ > 37 │ if (foo) { (this || {}).bar; } │ ^^^^^^^^^^^^^^^^ 38 │ if ((this || {}).bar) { foo.bar; } 39 │ i Unsafe fix: Change to an optional chain. 35 35 │ ((this || {}).foo2 || {}).foo3; 36 36 │ 37 │ - if·(foo)·{·(this·||·{}).bar;·} 37 │ + if·(foo)·{·this?.bar;·} 38 38 │ if ((this || {}).bar) { foo.bar; } 39 39 │ ``` ``` nullishAndLogicalOr2.ts:38:5 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 37 │ if (foo) { (this || {}).bar; } > 38 │ if ((this || {}).bar) { foo.bar; } │ ^^^^^^^^^^^^^^^^ 39 │ 40 │ (undefined && this || {}).bar; i Unsafe fix: Change to an optional chain. 36 36 │ 37 37 │ if (foo) { (this || {}).bar; } 38 │ - if·((this·||·{}).bar)·{·foo.bar;·} 38 │ + if·(this?.bar)·{·foo.bar;·} 39 39 │ 40 40 │ (undefined && this || {}).bar; ``` ``` nullishAndLogicalOr2.ts:40:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 38 │ if ((this || {}).bar) { foo.bar; } 39 │ > 40 │ (undefined && this || {}).bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 │ (this ?? {}).bar; 42 │ (this ?? ({})).bar; i Unsafe fix: Change to an optional chain. 38 38 │ if ((this || {}).bar) { foo.bar; } 39 39 │ 40 │ - (undefined·&&·this·||·{}).bar; 40 │ + (undefined·&&·this)?.bar; 41 41 │ (this ?? {}).bar; 42 42 │ (this ?? ({})).bar; ``` ``` nullishAndLogicalOr2.ts:41:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 40 │ (undefined && this || {}).bar; > 41 │ (this ?? {}).bar; │ ^^^^^^^^^^^^^^^^ 42 │ (this ?? ({})).bar; 43 │ (await this ?? {}).bar; i Unsafe fix: Change to an optional chain. 41 │ (this·??·{}).bar; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:42:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 40 │ (undefined && this || {}).bar; 41 │ (this ?? {}).bar; > 42 │ (this ?? ({})).bar; │ ^^^^^^^^^^^^^^^^^^ 43 │ (await this ?? {}).bar; 44 │ i Unsafe fix: Change to an optional chain. 42 │ (this·??·({})).bar; │ - -- ------ ``` ``` nullishAndLogicalOr2.ts:43:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 41 │ (this ?? {}).bar; 42 │ (this ?? ({})).bar; > 43 │ (await this ?? {}).bar; │ ^^^^^^^^^^^^^^^^^^^^^^ 44 │ 45 │ const foo = (this ?? {}).baz; i Unsafe fix: Change to an optional chain. 41 41 │ (this ?? {}).bar; 42 42 │ (this ?? ({})).bar; 43 │ - (await·this·??·{}).bar; 43 │ + (await·this)?.bar; 44 44 │ 45 45 │ const foo = (this ?? {}).baz; ``` ``` nullishAndLogicalOr2.ts:45:13 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 43 │ (await this ?? {}).bar; 44 │ > 45 │ const foo = (this ?? {}).baz; │ ^^^^^^^^^^^^^^^^ 46 │ ((this ?? {}).foo2 ?? {}).foo3; 47 │ i Unsafe fix: Change to an optional chain. 45 │ const·foo·=·(this·??·{}).baz; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:46:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 45 │ const foo = (this ?? {}).baz; > 46 │ ((this ?? {}).foo2 ?? {}).foo3; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 │ 48 │ if (foo) { (this ?? {}).bar; } i Unsafe fix: Change to an optional chain. 46 │ ((this·??·{}).foo2·??·{}).foo3; │ -- -- ---- - ----- ``` ``` nullishAndLogicalOr2.ts:48:12 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 46 │ ((this ?? {}).foo2 ?? {}).foo3; 47 │ > 48 │ if (foo) { (this ?? {}).bar; } │ ^^^^^^^^^^^^^^^^ 49 │ if ((this ?? {}).bar) { foo.bar; } 50 │ i Unsafe fix: Change to an optional chain. 48 │ if·(foo)·{·(this·??·{}).bar;·} │ - - ----- ``` ``` nullishAndLogicalOr2.ts:49:5 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 48 │ if (foo) { (this ?? {}).bar; } > 49 │ if ((this ?? {}).bar) { foo.bar; } │ ^^^^^^^^^^^^^^^^ 50 │ 51 │ (undefined && this ?? {}).bar; i Unsafe fix: Change to an optional chain. 49 │ if·((this·??·{}).bar)·{·foo.bar;·} │ - - ----- ``` ``` nullishAndLogicalOr2.ts:51:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 49 │ if ((this ?? {}).bar) { foo.bar; } 50 │ > 51 │ (undefined && this ?? {}).bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 │ (((typeof this) as string) || {}).bar; 53 │ i Unsafe fix: Change to an optional chain. 49 49 │ if ((this ?? {}).bar) { foo.bar; } 50 50 │ 51 │ - (undefined·&&·this·??·{}).bar; 51 │ + (undefined·&&·this)?.bar; 52 52 │ (((typeof this) as string) || {}).bar; 53 53 │ ``` ``` nullishAndLogicalOr2.ts:52:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 51 │ (undefined && this ?? {}).bar; > 52 │ (((typeof this) as string) || {}).bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 53 │ 54 │ // this expression with private name i Unsafe fix: Change to an optional chain. 50 50 │ 51 51 │ (undefined && this ?? {}).bar; 52 │ - (((typeof·this)·as·string)·||·{}).bar; 52 │ + ((typeof·this)·as·string)?.bar; 53 53 │ 54 54 │ // this expression with private name ``` ``` nullishAndLogicalOr2.ts:55:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 54 │ // this expression with private name > 55 │ (this || {}).#bar; │ ^^^^^^^^^^^^^^^^^ 56 │ (this || ({})).#bar; 57 │ (await this || {}).#bar; i Unsafe fix: Change to an optional chain. 53 53 │ 54 54 │ // this expression with private name 55 │ - (this·||·{}).#bar; 55 │ + this?.#bar; 56 56 │ (this || ({})).#bar; 57 57 │ (await this || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:56:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 54 │ // this expression with private name 55 │ (this || {}).#bar; > 56 │ (this || ({})).#bar; │ ^^^^^^^^^^^^^^^^^^^ 57 │ (await this || {}).#bar; 58 │ const foo = (this || {}).#baz; i Unsafe fix: Change to an optional chain. 54 54 │ // this expression with private name 55 55 │ (this || {}).#bar; 56 │ - (this·||·({})).#bar; 56 │ + this?.#bar; 57 57 │ (await this || {}).#bar; 58 58 │ const foo = (this || {}).#baz; ``` ``` nullishAndLogicalOr2.ts:57:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 55 │ (this || {}).#bar; 56 │ (this || ({})).#bar; > 57 │ (await this || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^ 58 │ const foo = (this || {}).#baz; 59 │ i Unsafe fix: Change to an optional chain. 55 55 │ (this || {}).#bar; 56 56 │ (this || ({})).#bar; 57 │ - (await·this·||·{}).#bar; 57 │ + (await·this)?.#bar; 58 58 │ const foo = (this || {}).#baz; 59 59 │ ``` ``` nullishAndLogicalOr2.ts:58:13 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 56 │ (this || ({})).#bar; 57 │ (await this || {}).#bar; > 58 │ const foo = (this || {}).#baz; │ ^^^^^^^^^^^^^^^^^ 59 │ 60 │ ((this || {}).#foo2 || {}).#foo3; i Unsafe fix: Change to an optional chain. 56 56 │ (this || ({})).#bar; 57 57 │ (await this || {}).#bar; 58 │ - const·foo·=·(this·||·{}).#baz; 58 │ + const·foo·=·this?.#baz; 59 59 │ 60 60 │ ((this || {}).#foo2 || {}).#foo3; ``` ``` nullishAndLogicalOr2.ts:60:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 58 │ const foo = (this || {}).#baz; 59 │ > 60 │ ((this || {}).#foo2 || {}).#foo3; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 │ 62 │ if (foo) { (this || {}).#bar; } i Unsafe fix: Change to an optional chain. 58 58 │ const foo = (this || {}).#baz; 59 59 │ 60 │ - ((this·||·{}).#foo2·||·{}).#foo3; 60 │ + this?.#foo2?.#foo3; 61 61 │ 62 62 │ if (foo) { (this || {}).#bar; } ``` ``` nullishAndLogicalOr2.ts:62:12 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 60 │ ((this || {}).#foo2 || {}).#foo3; 61 │ > 62 │ if (foo) { (this || {}).#bar; } │ ^^^^^^^^^^^^^^^^^ 63 │ if ((this || {}).#bar) { foo.bar; } 64 │ i Unsafe fix: Change to an optional chain. 60 60 │ ((this || {}).#foo2 || {}).#foo3; 61 61 │ 62 │ - if·(foo)·{·(this·||·{}).#bar;·} 62 │ + if·(foo)·{·this?.#bar;·} 63 63 │ if ((this || {}).#bar) { foo.bar; } 64 64 │ ``` ``` nullishAndLogicalOr2.ts:63:5 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 62 │ if (foo) { (this || {}).#bar; } > 63 │ if ((this || {}).#bar) { foo.bar; } │ ^^^^^^^^^^^^^^^^^ 64 │ 65 │ (undefined && this || {}).#bar; i Unsafe fix: Change to an optional chain. 61 61 │ 62 62 │ if (foo) { (this || {}).#bar; } 63 │ - if·((this·||·{}).#bar)·{·foo.bar;·} 63 │ + if·(this?.#bar)·{·foo.bar;·} 64 64 │ 65 65 │ (undefined && this || {}).#bar; ``` ``` nullishAndLogicalOr2.ts:65:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 63 │ if ((this || {}).#bar) { foo.bar; } 64 │ > 65 │ (undefined && this || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 │ (this ?? {}).#bar; 67 │ (this ?? ({})).#bar; i Unsafe fix: Change to an optional chain. 63 63 │ if ((this || {}).#bar) { foo.bar; } 64 64 │ 65 │ - (undefined·&&·this·||·{}).#bar; 65 │ + (undefined·&&·this)?.#bar; 66 66 │ (this ?? {}).#bar; 67 67 │ (this ?? ({})).#bar; ``` ``` nullishAndLogicalOr2.ts:66:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 65 │ (undefined && this || {}).#bar; > 66 │ (this ?? {}).#bar; │ ^^^^^^^^^^^^^^^^^ 67 │ (this ?? ({})).#bar; 68 │ (await this ?? {}).#bar; i Unsafe fix: Change to an optional chain. 66 │ (this·??·{}).#bar; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:67:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 65 │ (undefined && this || {}).#bar; 66 │ (this ?? {}).#bar; > 67 │ (this ?? ({})).#bar; │ ^^^^^^^^^^^^^^^^^^^ 68 │ (await this ?? {}).#bar; 69 │ i Unsafe fix: Change to an optional chain. 67 │ (this·??·({})).#bar; │ - -- ------ ``` ``` nullishAndLogicalOr2.ts:68:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 66 │ (this ?? {}).#bar; 67 │ (this ?? ({})).#bar; > 68 │ (await this ?? {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^ 69 │ 70 │ const foo = (this ?? {}).#baz; i Unsafe fix: Change to an optional chain. 66 66 │ (this ?? {}).#bar; 67 67 │ (this ?? ({})).#bar; 68 │ - (await·this·??·{}).#bar; 68 │ + (await·this)?.#bar; 69 69 │ 70 70 │ const foo = (this ?? {}).#baz; ``` ``` nullishAndLogicalOr2.ts:70:13 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 68 │ (await this ?? {}).#bar; 69 │ > 70 │ const foo = (this ?? {}).#baz; │ ^^^^^^^^^^^^^^^^^ 71 │ ((this ?? {}).#foo2 ?? {}).#foo3; 72 │ i Unsafe fix: Change to an optional chain. 70 │ const·foo·=·(this·??·{}).#baz; │ - - ----- ``` ``` nullishAndLogicalOr2.ts:71:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 70 │ const foo = (this ?? {}).#baz; > 71 │ ((this ?? {}).#foo2 ?? {}).#foo3; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 │ 73 │ if (foo) { (this ?? {}).#bar; } i Unsafe fix: Change to an optional chain. 71 │ ((this·??·{}).#foo2·??·{}).#foo3; │ -- -- ---- - ----- ``` ``` nullishAndLogicalOr2.ts:73:12 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 71 │ ((this ?? {}).#foo2 ?? {}).#foo3; 72 │ > 73 │ if (foo) { (this ?? {}).#bar; } │ ^^^^^^^^^^^^^^^^^ 74 │ if ((this ?? {}).#bar) { foo.bar; } 75 │ i Unsafe fix: Change to an optional chain. 73 │ if·(foo)·{·(this·??·{}).#bar;·} │ - - ----- ``` ``` nullishAndLogicalOr2.ts:74:5 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 73 │ if (foo) { (this ?? {}).#bar; } > 74 │ if ((this ?? {}).#bar) { foo.bar; } │ ^^^^^^^^^^^^^^^^^ 75 │ 76 │ (undefined && this ?? {}).#bar; i Unsafe fix: Change to an optional chain. 74 │ if·((this·??·{}).#bar)·{·foo.bar;·} │ - - ----- ``` ``` nullishAndLogicalOr2.ts:76:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 74 │ if ((this ?? {}).#bar) { foo.bar; } 75 │ > 76 │ (undefined && this ?? {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 77 │ (((typeof this) as string) || {}).#bar; 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 i Unsafe fix: Change to an optional chain. 74 74 │ if ((this ?? {}).#bar) { foo.bar; } 75 75 │ 76 │ - (undefined·&&·this·??·{}).#bar; 76 │ + (undefined·&&·this)?.#bar; 77 77 │ (((typeof this) as string) || {}).#bar; 78 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 ``` ``` nullishAndLogicalOr2.ts:77:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 76 │ (undefined && this ?? {}).#bar; > 77 │ (((typeof this) as string) || {}).#bar; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 79 │ (foo() || {}).bar; i Unsafe fix: Change to an optional chain. 75 75 │ 76 76 │ (undefined && this ?? {}).#bar; 77 │ - (((typeof·this)·as·string)·||·{}).#bar; 77 │ + ((typeof·this)·as·string)?.#bar; 78 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 79 79 │ (foo() || {}).bar; ``` ``` nullishAndLogicalOr2.ts:79:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 77 │ (((typeof this) as string) || {}).#bar; 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 > 79 │ (foo() || {}).bar; │ ^^^^^^^^^^^^^^^^^ 80 │ ((foo || {}).bar() || {}).baz; i Unsafe fix: Change to an optional chain. 77 77 │ (((typeof this) as string) || {}).#bar; 78 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 79 │ - (foo()·||·{}).bar; 79 │ + foo()?.bar; 80 80 │ ((foo || {}).bar() || {}).baz; ``` ``` nullishAndLogicalOr2.ts:80:1 lint/complexity/useOptionalChain FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Change to an optional chain. 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 79 │ (foo() || {}).bar; > 80 │ ((foo || {}).bar() || {}).baz; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i Unsafe fix: Change to an optional chain. 78 78 │ // (new foo || {}).bar; // tracked here https://github.com/rome/tools/issues/3257 79 79 │ (foo() || {}).bar; 80 │ - ((foo·||·{}).bar()·||·{}).baz; 80 │ + foo?.bar()?.baz; ```