1# ArkCompiler Subsystem Changelog
2
3## cl.arkcompiler.1 TS Compiler Targets ECMAScript 2021, Upgrading from ECMAScript 2017
4
5**Access Level**
6
7Other
8
9**Reason for Change**
10
11In the OpenHarmony SDK, the **target** option of the TypeScript compiler is changed from ES2017 to ES2021.
12
13**Change Impact**
14
15In rare scenarios where the code uses ES2018-ES2021 syntax features with syntax errors, which are masked using the @ts-nocheck or @ts-ignore comment:
16
17Before the change, these syntax errors are masked using comments, and the compilation is successful.
18
19After the change, the check rules for these syntaxes are enhanced, and a compilation error may be reported.
20
21
22**Start API Level**
23
249
25
26**Change Since**
27
28OpenHarmony SDK 5.0.0.19
29
30**Key API/Component Changes**
31
32N/A
33
34**Adaptation Guide**
35
36Delete the @ts-nocheck and @ts-ignore comments and perform adaptation based on the compilation error messages. Refer to the examples below.
37
381. ES2018 Feature: **rest** Property
39    ```
40    // @ts-ignore
41    const {a, ...remaning, b} = {a: 1, b: 2, c: 3, d: 4};
42    //           ~~~~~~~~
43    // Masked error: A rest element must be last in a destructuring pattern.
44    ```
45    Suggestion: Delete the @ts-ignore comment and place the **rest** property at the end.
46    ```
47    const {a, b, ...remaning} = {a: 1, b: 2, c: 3, d: 4};
48    ```
49
502. ES2020 Feature: Optional Chaining Operator
51    ```
52    const object = { property: "hi" };
53    // @ts-ignore
54    object?.property = "hello";
55    // ~~~~~~~~~~~~~
56    // Masked error: The left-hand side of an assignment expression may not be an optional property access.
57    ```
58    Suggestion: Delete the @ts-ignore comment, check whether the object is null, and then assign a value.
59    ```
60    const object = { property: "hi" };
61    if (object !== undefined) {
62        object.property = "hello";
63    }
64    ```
65
663. ES2020 Feature: Nullish Coalescing Operator
67    ```
68    // @ts-nocheck
69    let a = null || undefined ?? "foo";
70    //      ~~~~~~~~~~~~~~~~~
71    // Masked error: '||' and '??' operations cannot be mixed without parentheses.
72    let b = true && undefined ?? "foo";
73    //      ~~~~~~~~~~~~~~~~~
74    // Masked error: '&&' and '??' operations cannot be mixed without parentheses.
75    ```
76    Suggestion: Delete the @ts-nocheck comment and add parentheses to ensure that the operation sequence meets the expectation.
77    ```
78    let a = (null || undefined) ?? "foo";
79    let b = (true && undefined) ?? "foo";
80    ```
81For other scenarios with incompatible changes, delete the @ts-nocheck and @ts-ignore comments and rectify the fault based on the compilation error messages.
82
83You can also set **targetESVersion** to **ES2017** in the project-level **build-profile.json5** file to continue using ECMAScript 2017.
84