regexFind: /\[([a-zA-Z_$][a-zA-Z0-9_$]*)\?\s*:\s*\w+\]/
regexReplace: [$1: string]Remove question mark from index signature parameter. Index signature parameters cannot be optional.
- interface MyInterface {
- [key?: string]: any
- }
+ interface MyInterface {
+ [key: string]: any
+ }Explanation: Index signature parameters cannot be optional, remove the question mark
- interface DataInterface {
- [prop?: string]: unknown
- }
+ interface DataInterface {
+ [prop: string]: unknown
+ }Explanation: Remove optional modifier from index signature parameter
npx tsc ./docs/1019/index.ts --noEmit --prettydocs/1019/index.ts:2:7 - error TS1019: An index signature parameter cannot have a question mark.
2 [key?: string]: any
~OR (without --pretty flag):
docs/1019/index.ts(2,7): error TS1019: An index signature parameter cannot have a question mark.