TypeScript allows this invalid syntax without any errors.
Decorator[Yield, Await] :
@ DecoratorMemberExpression[?Yield, ?Await]
@ DecoratorParenthesizedExpression[?Yield, ?Await]
@ DecoratorCallExpression[?Yield, ?Await]
DecoratorMemberExpression[Yield, Await] :
IdentifierReference[?Yield, ?Await]
DecoratorMemberExpression[?Yield, ?Await] . IdentifierName
DecoratorMemberExpression[?Yield, ?Await] . PrivateIdentifier
DecoratorParenthesizedExpression[Yield, Await] :
( Expression[+In, ?Yield, ?Await] )
DecoratorCallExpression[Yield, Await] :
DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
🔎 Search Terms
DecoratorCallExpression
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?target=99&ts=5.1.6#code/CYUwxgNghgTiAEEQBd4A8Bc8AUBKeAvAHzwDe8AnlnoSdpvFAHYUA0lWzF+xjL8AXwCwAKAACaPADoKeUZCgBnRfABmAe3VlhIoA
💻 Code
🙁 Actual behavior
TypeScript allows this invalid syntax without any errors.
🙂 Expected behavior
Here's the grammar (taken from the spec linked in the proposal):
My reading of this grammar is that TypeScript should only be allowing a single
Argumentsproduction at the end of the decorator. So I believe TypeScript should consider this example to be a syntax error. Here's what other decorator parsers do:Babel:
esbuild: