• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Non-declaration statements in namespaces are not supported
2
3Rule ``arkts-no-ns-statements``
4
5**Severity: error**
6
7ArkTS does not support statements in namespaces. Use a function to execute
8statements.
9
10
11## TypeScript
12
13
14```
15
16    namespace A {
17        export let x: number
18        x = 1
19    }
20
21```
22
23## ArkTS
24
25
26```
27
28    namespace A {
29        export let x: number
30
31        export function init() {
32          x = 1
33        }
34    }
35
36    // Initialization function should be called to execute statements:
37    A.init()
38
39```
40
41
42