3 ms·
What's not explained by the quoted excerpt? Instead of writing, e.g. `const n = <number>someValueThatYouKnowIsANumber;`, you should write `const n = someValueT
by wk_end 2y ago
What's not explained by the quoted excerpt?
Instead of writing, e.g. `const n = <number>someValueThatYouKnowIsANumber;`, you should write `const n = someValueThatYouKnowIsANumber as number;`
(well, really, you shouldn't write either, casts are bad. But, yknow.)
- paulddraper 2y agoI mean I have not seen anything to suggest that angle brackets are "legacy or discouraged"
- wk_end 2y agoThey're discouraged because they conflict with JSX. For instance, in the eslint documentation: > Most codebases will want to enforce not using angle-bracket style because it conflicts with JSX syntax, and is confusing when paired with generic syntax. https://typescript-eslint.io/rules/consistent-type-assertions/ https://typescript-eslint.io/rules/consistent-type-assertion...
- paulddraper 2y agoThat's true, but this tool is made for users not using TSX. (Or at least, they can't use this tool with it.)
- animuchan 2y agoThe phrasing sounds a bit odd: surely "most codebases" don't use JSX, so why would they enforce anything JSX-related.
- sureIy 2y agoI don’t think I’ve seen a single codebase using that pattern ever. With React being so popular and TS growing in popularity just about after React, people have settled on `as` assertions instead, whether they use JSX or not.