• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Type annotation in catch clause is not supported
2
3Rule ``arkts-no-types-in-catch``
4
5**Severity: error**
6
7In TypeScript, catch clause variable type annotation must be ``any`` or ``unknown``
8if specified. As ArkTS does not support these types, omit type annotations.
9
10
11## TypeScript
12
13
14```
15
16    try {
17        // some code
18    }
19    catch (a: unknown) {
20        // handle error
21    }
22
23```
24
25## ArkTS
26
27
28```
29
30    try {
31        // some code
32    }
33    catch (a) {
34        // handle error
35    }
36
37```
38
39## See also
40
41- Recipe 087:  ``throw`` statements cannot accept values of arbitrary types (``arkts-limited-throw``)
42
43
44