• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Destructuring variable declarations are not supported
2
3Rule ``arkts-no-destruct-decls``
4
5**Severity: error**
6
7ArkTS does not support destructuring variable declarations. This is a dynamic
8feature relying on structural compatibility. In addition, names in destructuring
9declarations must be equal to properties within destructured classes.
10
11
12## TypeScript
13
14
15```
16
17    class Point {
18        x: number = 0.0
19        y: number = 0.0
20    }
21
22    function returnZeroPoint(): Point {
23        return new Point()
24    }
25
26    let {x, y} = returnZeroPoint()
27
28```
29
30## ArkTS
31
32
33```
34
35    class Point {
36        x: number = 0.0
37        y: number = 0.0
38    }
39
40    function returnZeroPoint(): Point {
41        return new Point()
42    }
43
44    // Create an intermediate object and work with it field by field
45    // without name restrictions:
46    let zp = returnZeroPoint()
47    let x = zp.x
48    let y = zp.y
49
50```
51
52
53