--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.ts --- # Input ```ts // @ts-expect-error const bar = case1!!.bar; function case2(bar: number | undefined) { const bar1: number = bar!!!; } function case3(bar?: { n: number }) { return bar!?.n; } function case4(bar?: { n: number }) { return bar!?.(); } const bar2 = (case5!)!.bar; function case6(bar?: { n: number }) { return (bar!)?.n; } function case7(bar?: { n: number }) { return (bar)!?.n; } function case8(bar?: { n: number }) { return ((bar!))?.(); } class Case9 { method() { this.property!!; } } case10!!.prop = null; case11!?.[computedField]; case12!?.[a.b!!]; case13!!! = null case14!! = null if (case15!!) {} if (!case16!!) {} ``` # Diagnostics ``` invalid.ts:2:13 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 1 │ // @ts-expect-error > 2 │ const bar = case1!!.bar; │ ^^^^^^ 3 │ 4 │ function case2(bar: number | undefined) { i Safe fix: Remove extra non-null assertion. 2 │ const·bar·=·case1!!.bar; │ - ``` ``` invalid.ts:5:24 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 4 │ function case2(bar: number | undefined) { > 5 │ const bar1: number = bar!!!; │ ^^^^^ 6 │ } 7 │ i Safe fix: Remove extra non-null assertion. 5 │ ··const·bar1:·number·=·bar!!!; │ - ``` ``` invalid.ts:5:24 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 4 │ function case2(bar: number | undefined) { > 5 │ const bar1: number = bar!!!; │ ^^^^ 6 │ } 7 │ i Safe fix: Remove extra non-null assertion. 5 │ ··const·bar1:·number·=·bar!!!; │ - ``` ``` invalid.ts:9:10 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 8 │ function case3(bar?: { n: number }) { > 9 │ return bar!?.n; │ ^^^^ 10 │ } 11 │ i Safe fix: Remove extra non-null assertion. 9 │ ··return·bar!?.n; │ - ``` ``` invalid.ts:13:10 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 12 │ function case4(bar?: { n: number }) { > 13 │ return bar!?.(); │ ^^^^ 14 │ } 15 │ i Safe fix: Remove extra non-null assertion. 13 │ ··return·bar!?.(); │ - ``` ``` invalid.ts:16:15 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 14 │ } 15 │ > 16 │ const bar2 = (case5!)!.bar; │ ^^^^^^ 17 │ 18 │ function case6(bar?: { n: number }) { i Safe fix: Remove extra non-null assertion. 16 │ const·bar2·=·(case5!)!.bar; │ - ``` ``` invalid.ts:19:11 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 18 │ function case6(bar?: { n: number }) { > 19 │ return (bar!)?.n; │ ^^^^ 20 │ } 21 │ i Safe fix: Remove extra non-null assertion. 19 │ ··return·(bar!)?.n; │ - ``` ``` invalid.ts:23:10 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 22 │ function case7(bar?: { n: number }) { > 23 │ return (bar)!?.n; │ ^^^^^^ 24 │ } 25 │ i Safe fix: Remove extra non-null assertion. 23 │ ··return·(bar)!?.n; │ - ``` ``` invalid.ts:27:12 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 26 │ function case8(bar?: { n: number }) { > 27 │ return ((bar!))?.(); │ ^^^^ 28 │ } 29 │ i Safe fix: Remove extra non-null assertion. 27 │ ··return·((bar!))?.(); │ - ``` ``` invalid.ts:32:5 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 30 │ class Case9 { 31 │ method() { > 32 │ this.property!!; │ ^^^^^^^^^^^^^^ 33 │ } 34 │ } i Safe fix: Remove extra non-null assertion. 32 │ ····this.property!!; │ - ``` ``` invalid.ts:36:1 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 34 │ } 35 │ > 36 │ case10!!.prop = null; │ ^^^^^^^ 37 │ 38 │ case11!?.[computedField]; i Safe fix: Remove extra non-null assertion. 36 │ case10!!.prop·=·null; │ - ``` ``` invalid.ts:40:11 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 38 │ case11!?.[computedField]; 39 │ > 40 │ case12!?.[a.b!!]; │ ^^^^ 41 │ 42 │ case13!!! = null i Safe fix: Remove extra non-null assertion. 40 │ case12!?.[a.b!!]; │ - ``` ``` invalid.ts:42:1 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 40 │ case12!?.[a.b!!]; 41 │ > 42 │ case13!!! = null │ ^^^^^^^^ 43 │ 44 │ case14!! = null i Safe fix: Remove extra non-null assertion. 42 │ case13!!!·=·null │ - ``` ``` invalid.ts:42:1 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 40 │ case12!?.[a.b!!]; 41 │ > 42 │ case13!!! = null │ ^^^^^^^ 43 │ 44 │ case14!! = null i Safe fix: Remove extra non-null assertion. 42 │ case13!!!·=·null │ - ``` ``` invalid.ts:44:1 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 42 │ case13!!! = null 43 │ > 44 │ case14!! = null │ ^^^^^^^ 45 │ 46 │ if (case15!!) {} i Safe fix: Remove extra non-null assertion. 44 │ case14!!·=·null │ - ``` ``` invalid.ts:46:5 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 44 │ case14!! = null 45 │ > 46 │ if (case15!!) {} │ ^^^^^^^ 47 │ 48 │ if (!case16!!) {} i Safe fix: Remove extra non-null assertion. 46 │ if·(case15!!)·{} │ - ``` ``` invalid.ts:48:6 lint/suspicious/noExtraNonNullAssertion FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Forbidden extra non-null assertion. 46 │ if (case15!!) {} 47 │ > 48 │ if (!case16!!) {} │ ^^^^^^^ 49 │ i Safe fix: Remove extra non-null assertion. 48 │ if·(!case16!!)·{} │ - ```