Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.07 KB

File metadata and controls

54 lines (42 loc) · 1.07 KB

1025 - An index signature cannot have a trailing comma.

🔍 Regex Patterns

regexFind: /\[([a-zA-Z_$][a-zA-Z0-9_$]*\s*:\s*[^,]+),\]/
regexReplace: [$1]

💡 Suggestion

Remove trailing comma from index signature. Index signatures cannot have trailing commas.

📝 Examples

Example 1: Basic trailing comma in index signature

interface MyInterface {
-  [key: string,]: any
+  [key: string]: any
}

Explanation: Remove trailing comma from index signature

Example 2: Different variable name

interface DataInterface {
-  [prop: string,]: unknown
+  [prop: string]: unknown
}

Explanation: Index signatures cannot have trailing commas

🖼️ Visual Output

Command

npx tsc ./docs/1025/index.ts --noEmit --pretty

Result

docs/1025/index.ts:2:15 - error TS1025: An index signature cannot have a trailing comma.

2   [key: string,]: any
                ~

OR (without --pretty flag):

docs/1025/index.ts(2,15): error TS1025: An index signature cannot have a trailing comma.