• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ArkUI Subsystem Changelog
2
3## cl.arkui.1 Validation Changes for the @Require Decorator on Regular Variables and @State or @Provide Decorated Variables
4
5**Access Level**
6
7Public API
8
9**Reason for Change**
10
11Enhancements to the @Require decorator are made to include value assignment verification for regular variables and \@State or \@Provide decorated variables.
12
13**Change Impact**
14
15Before change: @Require only supports the verification for @Prop and @BuilderParam decorators.
16
17After change: @Require supports the verification for regular variables and @Prop, @BuilderParam, @State, or @Provide decorated variables.
18
19The following is an example of incorrect code:
20
21```ts
22@Entry
23@Component
24struct Index {
25  @State message: string = 'Hello World';
26
27  @Builder buildTest() {
28    Row() {
29      Text('Hello, world')
30        .fontSize(30)
31    }
32  }
33
34  build() {
35    Row() {
36      Child()
37    }
38  }
39}
40
41@Component
42struct Child {
43  @Builder buildFuction() {
44    Column() {
45      Text('initBuilderParam')
46        .fontSize(30)
47    }
48  }
49  // As @Require is used here, parameters must be passed in to the constructor.
50  @Require regular_value: string = 'Hello';
51  @Require @State state_value: string = "Hello";
52  @Require @Provide provide_value: string = "Hello";
53  @Require @BuilderParam initbuildTest: () => void = this.buildFuction;
54  @Require @Prop initMessage: string = 'Hello';
55
56  build() {
57    Column() {
58      Text(this.initMessage)
59        .fontSize(30)
60      this.initbuildTest();
61    }
62  }
63}
64```
65
66Below is an example of correct usage:
67```ts
68@Entry
69@Component
70struct Index {
71  @State message: string = 'Hello World';
72
73  @Builder buildTest() {
74    Row() {
75      Text('Hello, world')
76        .fontSize(30)
77    }
78  }
79
80  build() {
81    Row() {
82      Child({ regular_value: this.message, state_value: this.message, provide_value: this.message, initMessage: this.message, message: this.message,
83        buildTest: this.buildTest, initbuildTest: this.buildTest })
84    }
85  }
86}
87
88@Component
89struct Child {
90  @Builder buildFuction() {
91    Column() {
92      Text('initBuilderParam')
93        .fontSize(30)
94    }
95  }
96  @Require regular_value: string = 'Hello';
97  @Require @State state_value: string = "Hello";
98  @Require @Provide provide_value: string = "Hello";
99  @Require @BuilderParam buildTest: () => void;
100  @Require @BuilderParam initbuildTest: () => void = this.buildFuction;
101  @Require @Prop initMessage: string = 'Hello';
102  @Require @Prop message: string;
103
104  build() {
105    Column() {
106      Text(this.initMessage)
107        .fontSize(30)
108      Text(this.message)
109        .fontSize(30)
110      this.initbuildTest();
111      this.buildTest();
112    }
113    .width('100%')
114    .height('100%')
115  }
116}
117```
118
119**Start API Level**
120
12112
122
123**Change Since**
124
125OpenHarmony SDK 5.0.0.12
126
127**Adaptation Guide**
128
129Adjust the @Require variable values based on the provided error messages.
130
131**Reference**
132
133[\@Require Decorator: Validating Constructor Input Parameters](https://gitee.com/openharmony/docs/blob/master/en/application-dev/quick-start/arkts-require.md)
134
135
136## cl.arkui.2 Restrictions on Using Access Qualifiers for Custom Component Member Properties
137
138**Access Level**
139
140Public API
141
142**Reason for Change**
143
144To enforce proper use of access qualifiers (**private**, **public**, and **protected**) in accordance with specifications, compilation verification is required.
145
146**Change Impact**
147
148The console outputs warning logs when incorrect usage is detected.
149
150The following is an example of incorrect usage:
151
1521. When a member variable is decorated by both the **private** access qualifier and the @State, @Prop, @Provide, or @BuilderParam decorator, the parent component **AccessRestrictions** uses the custom component **ComponentsChild** to construct and assign values. However, **ComponentsChild**'s private attributes do not support external construction and assignment. Therefore, ArkTS generates a warning log.
153
154```ts
155@Entry
156@Component
157struct AccessRestrictions {
158  @Builder buildTest() {
159    Text("Parent builder")
160  }
161  build() {
162    Column() {
163      ComponentsChild({state_value: "Hello", prop_value: "Hello", provide_value: "Hello", builder_value: this.buildTest, regular_value: "Hello"})
164    }
165    .width('100%')
166  }
167}
168
169@Component
170struct ComponentsChild {
171  @State private state_value: string = "Hello";
172  @Prop private prop_value: string = "Hello";
173  @Provide private provide_value: string = "Hello";
174  @BuilderParam private builder_value: () => void = this.buildTest;
175  private regular_value: string = "Hello";
176  @Builder buildTest() {
177    Text("Child builder")
178  }
179  build() {
180    Column() {
181      Text("Hello")
182        .fontSize(50)
183        .fontWeight(FontWeight.Bold)
184    }
185  }
186}
187```
188
1892. Member variables decorated by @StorageLink, @StorageProp, @LocalStorageLink, or @Consume can only be modified by private members. Therefore, when they are decorated by the **private** access qualifier, ArkTS generates a warning log.
190
191```ts
192@Entry
193@Component
194struct AccessRestrictions {
195  build() {
196    Column() {
197      ComponentChild()
198    }
199    .width('100%')
200  }
201}
202
203@Component
204struct ComponentChild {
205  @LocalStorageProp("sessionLocalProp") public local_prop_value: string = "Hello";
206  @LocalStorageLink("sessionLocalLink") public local_link_value: string = "Hello";
207  @StorageProp("sessionProp") public storage_prop_value: string = "Hello";
208  @StorageLink("sessionLink") public storage_link_value: string = "Hello";
209  @Consume public consume_value: string;
210  build() {
211    Column() {
212      Text("Hello")
213        .fontSize(50)
214        .fontWeight(FontWeight.Bold)
215    }
216  }
217}
218```
219
2203. The @Link or @ObjectLink decorated variables can only be initialized from the parent components. Therefore, when they are decorated by the **private** access qualifier, ArkTS generates a warning log.
221
222```ts
223@Entry
224@Component
225struct AccessRestrictions {
226  build() {
227    Column() {
228      ComponentChild({link_value: "Hello", objectLink_value: new ComponentObj()})
229    }
230    .width('100%')
231  }
232}
233
234@Observed
235class ComponentObj {
236  count: number = 0;
237}
238@Component
239struct ComponentChild {
240  @Link private link_value: string;
241  @ObjectLink private objectLink_value: ComponentObj;
242  build() {
243    Column() {
244      Text("Hello")
245        .fontSize(50)
246        .fontWeight(FontWeight.Bold)
247    }
248  }
249}
250```
251
2524. Custom components do not support inheritance. Therefore, when they are decorated by the **protected** access qualifier, ArkTS generates a warning log.
253
254```ts
255@Entry
256@Component
257struct AccessRestrictions {
258  build() {
259    Column() {
260      ComponentChild({regular_value: "Hello"})
261    }
262    .width('100%')
263  }
264}
265
266@Component
267struct ComponentChild {
268  protected regular_value: string = "Hello";
269  build() {
270    Column() {
271      Text("Hello")
272        .fontSize(50)
273        .fontWeight(FontWeight.Bold)
274    }
275  }
276}
277```
278
2795. The @Require decorator requires external construction and assignment, which is not supported for private members. Therefore, when a member variable is decorated by the **private** access qualifier, the @Require decorator, and the @State, @Prop, @Provide, or @BuilderParam decorator, ArkTS generates a warning log.
280
281```ts
282@Entry
283@Component
284struct AccessRestrictions {
285  build() {
286    Column() {
287      ComponentChild({prop_value: "Hello"})
288    }
289    .width('100%')
290  }
291}
292@Component
293struct ComponentChild {
294  @Require @Prop private prop_value: string = "Hello";
295  build() {
296    Column() {
297      Text("Hello")
298        .fontSize(50)
299        .fontWeight(FontWeight.Bold)
300    }
301  }
302}
303```
304
305**API Level**
306
30712
308
309**Change Since**
310
311OpenHarmony SDK 5.0.0.12
312
313**Adaptation Guide**
314
315Adjust the use of access qualifiers based on the provided error messages.
316
317**Reference**
318
319[Constraints on Access Modifiers of Custom Component Member Variables](https://gitee.com/openharmony/docs/blob/master/en/application-dev/quick-start/arkts-custom-components-access-restrictions.md)
320
321
3226. The **onFrame**, **onFinish**, **onCancel**, and **onRepeat** APIs in **AnimatorResult** do not adhere to syntax specifications.
323
324**API Level**
325
32612
327
328**Change Since**
329
330OpenHarmony SDK 5.0.0.12
331
332**Adaptation Guide**
333
334For inheritence from **AnimatorResult**, implement the **onFrame**, **onFinish**, **onCancel**, and **onRepeat** APIs.
335
336**Reference**
337
338[@ohos.animator (Animator)](../../../application-dev/reference/apis-arkui/js-apis-animator.md)
339