• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Only one static block is supported
2
3Rule ``arkts-no-multiple-static-blocks``
4
5**Severity: error**
6
7ArkTS does not allow having several static blocks for class initialization.
8Combine static block statements into one static block.
9
10
11## TypeScript
12
13
14```
15
16    class C {
17        static s: string
18
19        static {
20            C.s = "aa"
21        }
22        static {
23            C.s = C.s + "bb"
24        }
25    }
26
27```
28
29## ArkTS
30
31
32```
33
34
35    class C {
36        static s: string
37
38        static {
39            C.s = "aa"
40            C.s = C.s + "bb"
41        }
42    }
43
44
45```
46
47
48