Closed pauldraper closed 1 month ago
There's some context as to why this is not supported in the unsupported_syntax docs:
The reason
ts-blank-space
doesn't support the prefix style is because there are situations where erasing it would change the runtime semantics of the remaining JavaScript.
There are then worked examples, the second of which cannot be accommodated in the same "footprint" as the original source, meaning that source maps would be required for accurate debugging.
In terms of the legacy/discouraged-ness of these kind of type assertions, it's not as clear-cut as some of the other syntaxes which have clearer guidance. Some data points:
<>
style assertions create ambiguous/awkward parse situations with JSX syntax which uses <>
to mean something else
as
-style assertions were introduced to remedy this in TypeScript 1.6<>
syntax and work in places that it does notas
, demonstrating <>
only onceas
Thanks for the explanation.
Thanks for the question! We're not currently planning to support this at the moment, so will close this Issue for now.
Is your feature request related to a problem? Please describe.
Support angle bracket type assertion, e.g.
Describe the solution you'd like
Strip the cast, e.g.
Describe alternatives you've considered
Use "as" syntax.
That is not feasible with some codebases that prefer that styles (
{"@typescript-eslint/consistent-type-assertions":{assertionStyle:"angle-bracket"}}
)Additional context
The documentation incorrectly characterizes angle bracket type assertion as "legacy or discouraged."
Please correct me if this TypeScript feature is in fact legacy/discouraged (and by whom!).