Duolith docs

Errors E0300 to E0399

E0345 Name read from an index signature

Message {TypeScript's message} (TSnumber)

Words in italics are filled in when the compiler reports it, such as the element's name or the list of known ones.

Why

The object has keys that are not known in advance, such as a route's query, so query.next looks like a known field but may not be there at all. Duolith checks with noPropertyAccessFromIndexSignature so that such reads look different from reads of known fields, and noUncheckedIndexedAccess so that their value may be undefined.

How to fix it

Write query["next"], and handle the value being undefined, such as query["next"] ?? "/".

In a terminal

duolith explain E0345

Mentioned in