Skip to content

typeAssertionStyles

Reports angle-bracket type assertions.

✅ This rule is included in the ts stylistic preset.

TypeScript supports two syntaxes for type assertions: angle-bracket (<Type>value) and as (value as Type). The angle-bracket syntax is ambiguous with JSX and should be avoided.

const value = <string>raw;
const items = <Array<string>>getData();

This rule is not configurable.

If your project doesn’t use JSX and you prefer the angle-bracket syntax for consistency with legacy styles, you might prefer to disable this rule.