1 | # Enforces the use of `as Type` assertions instead of `<Type>` assertions (no-angle-bracket-type-assertion)
|
2 |
|
3 | TypeScript disallows the use of `<Type>` assertions in `.tsx` because of the similarity with
|
4 | JSX's syntax, which makes it impossible to parse.
|
5 |
|
6 | ## Rule Details
|
7 |
|
8 | This rule aims to standardise the use of type assertion style across the codebase
|
9 |
|
10 | The following patterns are considered warnings:
|
11 |
|
12 | ```ts
|
13 | const foo = <Foo>bar;
|
14 | ```
|
15 |
|
16 | The following patterns are not warnings:
|
17 |
|
18 | ```ts
|
19 | const foo = bar as Foo;
|
20 | ```
|
21 |
|
22 | ## When Not To Use It
|
23 |
|
24 | If 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/)
|