A type assertion is written <T>value instead of value as T
What it finds
<User>data: the angle-bracket form of a type assertion cannot be used in .tsx files, where it reads as a JSX tag, and it binds differently from as, which reads in the order the code runs. data as User works everywhere.
The fix rewrites the assertion to (data as User), in parentheses so that it binds as before, and is safe.
From the rule's source, angle_bracket_assertion.rs.
declare const data: unknown;const user = <string>data;tx0 reports: write this assertion with asconst other = data as string; Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:angle-bracket-assertion" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:angle-bracket-assertion] reason="..."tx0 explain tx0/ts:angle-bracket-assertion shows the same in the terminal. Found a false positive? Report it.