'SolidJS: Typescript error says value is of type 'undefined' despite checking that it isn't

I have some SolidJS code like:

{value() !== undefined && <img src={srcs[value()]} />}

where value is a signal. I get a TypeScript error under value() saying Type 'undefined' cannot be used as an index type.ts(2538)

What does this mean and how do I fix this without // @ts-ignore?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source