• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Definite assignment assertions are not supported
2
3Rule ``arkts-no-definite-assignment``
4
5**Severity: warning**
6
7ArkTS does not support definite assignment assertions ``let v!: T`` because
8they are considered an excessive compiler hint.
9Use declaration with initialization instead.
10
11
12## TypeScript
13
14
15```
16
17    let x!: number // Hint: x will be initialized before usage
18
19    initialize()
20
21    function initialize() {
22        x = 10
23    }
24
25    console.log("x = " + x)
26
27```
28
29## ArkTS
30
31
32```
33
34    function initialize() : number {
35        return 10
36    }
37
38    let x: number = initialize()
39
40    console.log("x = " + x)
41
42```
43
44
45