typescript
Mapped type needed instead of index signature
An index signature parameter type cannot be a literal type or generic type
Fixes
- 1.Use a mapped type [K in 'key1' | 'key2']: ValueType instead of index signature
- 2.Use Record<'key1' | 'key2', ValueType> utility type
- 3.For generic keys, use a mapped type: { [K in T]: ValueType }
typescriptmapped-typesindex-signature
Related Errors
typescript3 fixes
TS2304: Cannot find name 'X'
TS2304.*Cannot find name
- •Import the type/value
- •Install @types/ package
typescript3 fixes
TS2305: Module has no exported member
TS2305.*has no exported member
- •Check export name spelling
- •Verify package version has that export
typescript3 fixes
TS2307: Cannot find module or its type declarations
TS2307.*Cannot find module
- •Install the package or @types/ package
- •Add module declaration in .d.ts file