--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.ts --- # Input ```ts export interface I { ["p1"]: number "p2": number get ["p3"](): number get "p4"(): number set ["p3"](x: number) set "p4"(x: number) ["m1"](): void "m2"(): void [""]: number } export type T = { ["p1"]: number "p2": number get ["p3"](): number get "p4"(): number set ["p3"](x: number) set "p4"(x: number) ["m1"](): void "m2"(): void [""]: number } ``` # Diagnostics ``` invalid.ts:2:3 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 1 │ export interface I { > 2 │ ["p1"]: number │ ^^^^ 3 │ 4 │ "p2": number i Unsafe fix: Use a literal key instead. 2 │ → ["p1"]:·number │ -- -- ``` ``` invalid.ts:4:2 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 2 │ ["p1"]: number 3 │ > 4 │ "p2": number │ ^^^^ 5 │ 6 │ get ["p3"](): number i Unsafe fix: Use a literal key instead. 4 │ → "p2":·number │ - - ``` ``` invalid.ts:6:7 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 4 │ "p2": number 5 │ > 6 │ get ["p3"](): number │ ^^^^ 7 │ 8 │ get "p4"(): number i Unsafe fix: Use a literal key instead. 6 │ → get·["p3"]():·number │ -- -- ``` ``` invalid.ts:8:6 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 6 │ get ["p3"](): number 7 │ > 8 │ get "p4"(): number │ ^^^^ 9 │ 10 │ set ["p3"](x: number) i Unsafe fix: Use a literal key instead. 8 │ → get·"p4"():·number │ - - ``` ``` invalid.ts:10:7 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 8 │ get "p4"(): number 9 │ > 10 │ set ["p3"](x: number) │ ^^^^ 11 │ 12 │ set "p4"(x: number) i Unsafe fix: Use a literal key instead. 10 │ → set·["p3"](x:·number) │ -- -- ``` ``` invalid.ts:12:6 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 10 │ set ["p3"](x: number) 11 │ > 12 │ set "p4"(x: number) │ ^^^^ 13 │ 14 │ ["m1"](): void i Unsafe fix: Use a literal key instead. 12 │ → set·"p4"(x:·number) │ - - ``` ``` invalid.ts:14:3 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 12 │ set "p4"(x: number) 13 │ > 14 │ ["m1"](): void │ ^^^^ 15 │ 16 │ "m2"(): void i Unsafe fix: Use a literal key instead. 14 │ → ["m1"]():·void │ -- -- ``` ``` invalid.ts:16:2 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 14 │ ["m1"](): void 15 │ > 16 │ "m2"(): void │ ^^^^ 17 │ 18 │ [""]: number i Unsafe fix: Use a literal key instead. 16 │ → "m2"():·void │ - - ``` ``` invalid.ts:18:3 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 16 │ "m2"(): void 17 │ > 18 │ [""]: number │ ^^ 19 │ } 20 │ i Unsafe fix: Use a literal key instead. 18 │ → [""]:·number │ - - ``` ``` invalid.ts:22:3 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 21 │ export type T = { > 22 │ ["p1"]: number │ ^^^^ 23 │ 24 │ "p2": number i Unsafe fix: Use a literal key instead. 22 │ → ["p1"]:·number │ -- -- ``` ``` invalid.ts:24:2 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 22 │ ["p1"]: number 23 │ > 24 │ "p2": number │ ^^^^ 25 │ 26 │ get ["p3"](): number i Unsafe fix: Use a literal key instead. 24 │ → "p2":·number │ - - ``` ``` invalid.ts:26:7 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 24 │ "p2": number 25 │ > 26 │ get ["p3"](): number │ ^^^^ 27 │ 28 │ get "p4"(): number i Unsafe fix: Use a literal key instead. 26 │ → get·["p3"]():·number │ -- -- ``` ``` invalid.ts:28:6 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 26 │ get ["p3"](): number 27 │ > 28 │ get "p4"(): number │ ^^^^ 29 │ 30 │ set ["p3"](x: number) i Unsafe fix: Use a literal key instead. 28 │ → get·"p4"():·number │ - - ``` ``` invalid.ts:30:7 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 28 │ get "p4"(): number 29 │ > 30 │ set ["p3"](x: number) │ ^^^^ 31 │ 32 │ set "p4"(x: number) i Unsafe fix: Use a literal key instead. 30 │ → set·["p3"](x:·number) │ -- -- ``` ``` invalid.ts:32:6 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 30 │ set ["p3"](x: number) 31 │ > 32 │ set "p4"(x: number) │ ^^^^ 33 │ 34 │ ["m1"](): void i Unsafe fix: Use a literal key instead. 32 │ → set·"p4"(x:·number) │ - - ``` ``` invalid.ts:34:3 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 32 │ set "p4"(x: number) 33 │ > 34 │ ["m1"](): void │ ^^^^ 35 │ 36 │ "m2"(): void i Unsafe fix: Use a literal key instead. 34 │ → ["m1"]():·void │ -- -- ``` ``` invalid.ts:36:2 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 34 │ ["m1"](): void 35 │ > 36 │ "m2"(): void │ ^^^^ 37 │ 38 │ [""]: number i Unsafe fix: Use a literal key instead. 36 │ → "m2"():·void │ - - ``` ``` invalid.ts:38:3 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The computed expression can be simplified without the use of a string literal. 36 │ "m2"(): void 37 │ > 38 │ [""]: number │ ^^ 39 │ } 40 │ i Unsafe fix: Use a literal key instead. 38 │ → [""]:·number │ - - ```