Closed kevinbarabash closed 1 year ago
I thought about this a bit more and it doesn't make sense for the tree-sitter parser to do this check since it's a semantic issue. Sorry for the noise.
No problem @kevinbarabash! This one is on the edge, I'd say. Because the rest pattern cannot appear anywhere with the optional (or probably any) annotation, it would be fine to rule it out in the grammar.
The following piece of code is parsed without error by tree-sitter-typescript.
Here's a link to the TypeScript Playground showing that rest params cannot be marked as optional: https://www.typescriptlang.org/play?#code/MYewdgzgLgBAZiEMC8MAUBDAXDMBXAWwCMBTAJwBoYA6Wogfh32PIG0BdAShwDcQBLACYoAfDADeAXwBQMOUA
I was expecting there to be an
ERROR
node after therest_parameter
and the enclosingoptional_parameter
to be arequired_parameter
.