Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

1013 - A rest parameter or binding pattern may not have a trailing comma.

🔍 Regex Patterns

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

💡 Suggestion

Remove trailing comma after rest parameter or binding pattern

📝 Examples

Example 1: Rest parameter with trailing comma

- function greet(...names,) {
+ function greet(...names) {
  return `Hello ${names.join(', ')}`
}

Explanation: Rest parameters cannot have trailing commas

Example 2: Arrow function rest parameter with trailing comma

- const greetArrow = (...names,) => {
+ const greetArrow = (...names) => {
  return `Hello ${names.join(', ')}`
}

Explanation: Arrow function rest parameters cannot have trailing commas

🖼️ Visual Output

Command

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

Result

docs/1013/index.ts:2:24 - error TS1013: A rest parameter or binding pattern may not have a trailing comma.

2 function greet(...names,) {
                         ~

docs/1013/index.ts:7:29 - error TS1013: A rest parameter or binding pattern may not have a trailing comma.

7 const greetArrow = (...names,) => {
                              ~

OR (without --pretty flag):

docs/1013/index.ts(2,24): error TS1013: A rest parameter or binding pattern may not have a trailing comma.
docs/1013/index.ts(7,29): error TS1013: A rest parameter or binding pattern may not have a trailing comma.