UNPKG

856 BMarkdownView Raw
1# Enforces the use of `as Type` assertions instead of `<Type>` assertions (no-angle-bracket-type-assertion)
2
3TypeScript disallows the use of `<Type>` assertions in `.tsx` because of the similarity with
4JSX's syntax, which makes it impossible to parse.
5
6## Rule Details
7
8This rule aims to standardise the use of type assertion style across the codebase
9
10The following patterns are considered warnings:
11
12```ts
13const foo = <Foo>bar;
14```
15
16The following patterns are not warnings:
17
18```ts
19const foo = bar as Foo;
20```
21
22## When Not To Use It
23
24If your codebase does not include `.tsx` files, then you will not need this rule.
25
26## Further Reading
27
28* [Typescript and JSX](https://www.typescriptlang.org/docs/handbook/jsx.html)
29
30## Compatibility
31
32* TSLint: [no-angle-bracket-type-assertion](https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/)