1e41f4b71Sopenharmony_ci# ArkCompiler Subsystem Changelog
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## cl.ArkCompiler.1 ArkTS Syntax Validator Change
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciCompared with OpenHarmony SDK 4.0.10.8, the syntax validator in OpenHarmony SDK 4.0.10.10/11 is able to detect violations of the following rules and reports corresponding errors.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci> **NOTE**
8e41f4b71Sopenharmony_ci> This change is only an enhancement of the syntax validator capability. The syntax rules below are not new rules themselves.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci### Rule arkts-no-classes-as-obj
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciThis rule checks usage of an imported class as a variable. Below is an example:
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci ```ts
15e41f4b71Sopenharmony_ci// module1.ets
16e41f4b71Sopenharmony_ciexport class C {}
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci// module2.ets
19e41f4b71Sopenharmony_ciimport { C } from './module1'
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_cilet c = C  // error: arkts-no-class-as-obj
22e41f4b71Sopenharmony_ci ```
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**Change Impact**
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciCode adaptation is required. Otherwise, the compilation fails.
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**Key API/Component Changes**
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ciThe ArkTS syntax validator is enhanced.
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci**Adaptation Guide**
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ciModify code files that do not comply with the ArkTS syntax rules. For details about the rules and modification suggestions, see [Adaptation Cases](../../../application-dev/quick-start/arkts-more-cases.md#arkts-no-classes-as-obj).
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci### Rule arkts-strict-typing
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ciThis rule checks assignment of values of the **X | undefined** type to an entity of the **X** type in the .ets file. Below is an example:
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci ```ts
41e41f4b71Sopenharmony_ci// module.ets
42e41f4b71Sopenharmony_cifunction foo(a: number) {
43e41f4b71Sopenharmony_ci  return a + 1
44e41f4b71Sopenharmony_ci}
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_cifunction bar(x: number): number | undefined {
47e41f4b71Sopenharmony_ci  return x > 0 ? x : undefined
48e41f4b71Sopenharmony_ci}
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_cifoo(bar(-123))  // error: arkts-strict-typing
51e41f4b71Sopenharmony_ci ```
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ciThis rule checks assignment of values of the **X | null** type to an entity of the **X** type in the .ets file. Below is an example:
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci ```ts
56e41f4b71Sopenharmony_ci// module.ets
57e41f4b71Sopenharmony_cifunction foo(a: number) {
58e41f4b71Sopenharmony_ci  return a + 1
59e41f4b71Sopenharmony_ci}
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_cifunction bar(x: number): number | null {
62e41f4b71Sopenharmony_ci  return x > 0 ? x : null
63e41f4b71Sopenharmony_ci}
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_cifoo(bar(-123))  // error: arkts-strict-typing
66e41f4b71Sopenharmony_ci ```
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci**Change Impact**
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ciCode adaptation is required. Otherwise, the compilation fails.
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci**Key API/Component Changes**
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ciThe ArkTS syntax validator is enhanced.
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**Adaptation Guide**
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ciModify code files that do not comply with the ArkTS syntax rules. For details about the rules and modification suggestions, see [Adaptation Cases](../../../application-dev/quick-start/arkts-more-cases.md#arkts-strict-typingstrictmodeerror).
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci### Rule arkts-no-ts-deps
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ciThis rule checks imports of entities from an .ets file to a .ts file. Below is an example:
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci ```ts
86e41f4b71Sopenharmony_ci// lib.ts
87e41f4b71Sopenharmony_ciexport class C {}
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci// module.ets
91e41f4b71Sopenharmony_ciimport { C } from './lib'
92e41f4b71Sopenharmony_ci ```
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**Change Impact**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ciCode adaptation is required. Otherwise, the compilation fails.
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci**Key API/Component Changes**
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ciThe ArkTS syntax validator is enhanced.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci**Adaptation Guide**
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ciModify code files that do not comply with the ArkTS syntax rules. For details about the rules and modification suggestions, see [Adaptation Cases](../../../application-dev/quick-start/arkts-more-cases.md#arkts-no-tsdeps).
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci## cl.ArkCompiler.2 ArkTS Syntax Rule Change
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ciAdded ArkTS syntax rule levels: error and warning.
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci- **Error**: constraint with which compliance is mandatory. An error will result in a compilation failure.
111e41f4b71Sopenharmony_ci- **Warning**: constraint with which compliance is recommended. A warning does not affect the compilation process, but may cause compilation failures in the future.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ciSince 4.0.10.11, the levels of rules **arkts-no-definite-assignment** and **arkts-no-decorators-except-arkui** are degraded to warning. If **ESObject** is used in code, a warning is reported.
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ciIn addition, the ArkTS syntax supports the following features:
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**tuple**, **keyof**, **for-of**, use of expansion characters in array scenarios, re-export, module name suffixed with .js, **readonly**, **Encode**, **Decode**, **ParesHexOctet**, **Array.isArray**, **Object.entries**, **Object.keys**, **Object.values**, **Object.hasOwn**, **Object.hasOwnPropertyNames**, **Reflect.get**, **Reflect.set**, **Reflect.has**, **Reflect.ownKeys**, **Reflect.set**, **Symbol.iterator**, and **Required** and **Readonly** in Utility types.
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci**Change Impact**
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciThere is no compatibility impact. No code adaptation is required.
122