• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Universal module definitions (UMD) are not supported
2
3Rule ``arkts-no-umd``
4
5**Severity: error**
6
7ArkTS does not support universal module definitions (UMD) because in the
8language there is no concept of "script" (as opposed to "module").
9Besides, in ArkTS import is a compile-time, not a runtime feature.
10Use ordinary syntax for ``export`` and ``import`` instead.
11
12
13## TypeScript
14
15
16```
17
18    // math-lib.d.ts
19    export const isPrime(x: number): boolean
20    export as namespace mathLib
21
22    // in script
23    mathLib.isPrime(2)
24
25```
26
27## ArkTS
28
29
30```
31
32    // math-lib.d.ts
33    namespace mathLib {
34        export isPrime(x: number): boolean
35    }
36
37    // in program
38    import { mathLib } from "math-lib"
39    mathLib.isPrime(2)
40
41```
42
43## See also
44
45- Recipe 129:  Wildcards in module names are not supported (``arkts-no-module-wildcards``)
46
47
48