@buaa_smat/hometrans 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +164 -112
  2. package/agents/build-fixer.md +384 -394
  3. package/agents/code-reviewer.md +240 -240
  4. package/agents/logic-coder.md +199 -199
  5. package/agents/logic-context-builder.md +194 -194
  6. package/agents/review-fixer.md +405 -405
  7. package/agents/self-test-fixer.md +296 -296
  8. package/agents/self-tester.md +393 -392
  9. package/agents/spec-generator.md +540 -540
  10. package/dist/cli/config-store.js +84 -8
  11. package/dist/cli/config.js +3 -3
  12. package/dist/cli/env-vars.js +129 -0
  13. package/dist/cli/init.js +272 -272
  14. package/dist/cli/uninstall.js +152 -17
  15. package/dist/context/index.js +10 -197
  16. package/env-requirements.json +3 -3
  17. package/package.json +1 -1
  18. package/resource/choose_editor.png +0 -0
  19. package/resource/common_config.png +0 -0
  20. package/resource/integration_test_config.png +0 -0
  21. package/resource/set_env.png +0 -0
  22. package/resource/ui_align_config.png +0 -0
  23. package/skills/hmos-batch-ui-align/SKILL.md +108 -98
  24. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +180 -180
  25. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  26. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  27. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  28. package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
  29. package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
  30. package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
  31. package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
  32. package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
  33. package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
  34. package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
  35. package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
  36. package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
  37. package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
  38. package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
  39. package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
  40. package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
  41. package/skills/hmos-convert-pipeline/SKILL.md +429 -415
  42. package/skills/hmos-fix-build-errors/SKILL.md +272 -273
  43. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
  44. package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
  45. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
  46. package/skills/hmos-incremental-ui-align/SKILL.md +219 -200
  47. package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
  48. package/skills/hmos-incremental-ui-align/page_align.md +62 -62
  49. package/skills/hmos-incremental-ui-align/readme.md +237 -230
  50. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +2 -2
  51. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
  52. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
  53. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
  54. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
  55. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
  56. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
  57. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
  58. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
  59. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
  60. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
  61. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
  62. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
  63. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
  64. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +3 -3
  65. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  66. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  67. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  68. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +37 -37
  69. package/skills/hmos-integration-test/SKILL.md +380 -369
  70. package/skills/hmos-integration-test/readme.md +309 -309
  71. package/skills/hmos-resources-convert/SKILL.md +623 -623
  72. package/skills/hmos-resources-convert/references/conversion-rules.md +663 -663
  73. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -388
  74. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -457
  75. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -513
  76. package/skills/hmos-spec-generate/SKILL.md +331 -331
  77. package/skills/hmos-spec-generate/references/android-platform-tokens.md +105 -105
  78. package/skills/hmos-spec-generate/references/spec-sample-1.md +78 -78
  79. package/skills/hmos-spec-generate/references/spec-sample-2.md +58 -58
  80. package/skills/hmos-spec-generate/references/spec-sample-3.md +116 -116
  81. package/skills/hmos-spec-generate/references/step4-report-template.md +33 -33
  82. package/tools/test-tools/autotest/README.md +33 -17
  83. package/tools/test-tools/autotest/self_test_runner.py +109 -15
  84. package/resource/hometrans_config.png +0 -0
  85. package/skills/hmos-incremental-ui-align/config-example.json +0 -11
  86. package/tools/test-tools/autotest/config.yaml.example +0 -58
@@ -1,219 +1,219 @@
1
- # ArkTS 严格模式确定性修复 Pattern
2
- # 适用于: ArkTS 严格模式编译错误
3
- # 触发场景: 编译报错 arkts-no-xxx 系列
4
- # 经验来源: EinkBro 迁移 (2026-03-26)
5
-
6
- ---
7
-
8
- ## Pattern 1: throw 语句
9
-
10
- ### 错误写法
11
- ```typescript
12
- throw err; // ERROR: arkts-limited-throw
13
- throw 'error string'; // ERROR: arkts-limited-throw
14
- throw unknownVariable; // ERROR: arkts-limited-throw
15
- ```
16
-
17
- ### 正确写法
18
- ```typescript
19
- throw new Error(String(error));
20
- ```
21
-
22
- ### 不需要修改的情况
23
- ```typescript
24
- throw new Error('specific message'); // OK - 已经是 Error 实例
25
- ```
26
-
27
- ---
28
-
29
- ## Pattern 2: 对象字面量作为参数 (arkts-no-untyped-obj-literals)
30
-
31
- ### 错误写法
32
- ```typescript
33
- // ERROR: Object literal must correspond to some explicitly declared class or interface
34
- const response = await this.sendRequest(url, { contents });
35
- ```
36
-
37
- ### 正确写法 — 先声明变量
38
- ```typescript
39
- interface GeminiRequestBody {
40
- contents: GeminiContent[];
41
- }
42
-
43
- const requestBody: GeminiRequestBody = { contents };
44
- const response = await this.sendRequest(url, requestBody);
45
- ```
46
-
47
- ### 内联参数场景
48
- ```typescript
49
- // 方法参数也是对象字面量,同样需要处理
50
- httpRequest.request(url, {
51
- method: http.RequestMethod.POST,
52
- header: { 'Content-Type': 'application/json' },
53
- extraData: JSON.stringify(body),
54
- connectTimeout: 30000,
55
- readTimeout: 30000
56
- });
57
- // ^ 这种场景 SDK 方法签名本身接受 object 类型,通常 OK
58
- // 但自定义方法调用时必须用已声明接口的变量
59
- ```
60
-
61
- ---
62
-
63
- ## Pattern 3: Margin vertical 简写不支持
64
-
65
- ### 错误写法
66
- ```typescript
67
- .margin({ vertical: 8 }); // ERROR: 'vertical' does not exist in type
68
- ```
69
-
70
- ### 正确写法
71
- ```typescript
72
- .margin({ top: 8, bottom: 8 });
73
- ```
74
-
75
- ### 常见场景
76
- | 错误 | 正确 |
77
- |------|------|
78
- | `.margin({ vertical: 8 })` | `.margin({ top: 8, bottom: 8 })` |
79
- | `.margin({ horizontal: 16 })` | `.margin({ left: 16, right: 16 })` |
80
-
81
- ---
82
-
83
- ## Pattern 4: List 内不能直接放 Divider
84
-
85
- ### 错误写法
86
- ```typescript
87
- List() {
88
- ForEach(items, (item) => {
89
- ListItem() { /* ... */ }
90
- })
91
- Divider() // ERROR: List children must be ListItem only
92
- }
93
- ```
94
-
95
- ### 正确写法 — 用 ListItem + border
96
- ```typescript
97
- List() {
98
- ForEach(items, (item) => {
99
- ListItem() {
100
- Column() {
101
- Text(item.name)
102
- }
103
- .width('100%')
104
- .padding(12)
105
- .border({ width: { bottom: 1 }, color: '#E0E0E0' }) // 替代 Divider 分隔线
106
- }
107
- })
108
- }
109
- ```
110
-
111
- ### 另一种方案 — border 直接在 ListItem 上
112
- ```typescript
113
- ListItem() {
114
- // content
115
- }
116
- .border({ width: { bottom: 1 }, color: '#E0E0E0' })
117
- ```
118
-
119
- ---
120
-
121
- ## Pattern 5: 数组字面量类型推断 (arkts-no-noninferrable-arr-literals)
122
-
123
- ### 错误写法
124
- ```typescript
125
- const arr = [1, 2, 3].map(x => ({ val: x }));
126
- // ERROR: Array literals must contain elements of only inferrable types
127
- ```
128
-
129
- ### 正确写法 — 显式类型
130
- ```typescript
131
- interface Item { val: number; }
132
- const arr: Item[] = [1, 2, 3].map((x): Item => ({ val: x }));
133
- ```
134
-
135
- ---
136
-
137
- ## Pattern 6: TextDecoder 不存在
138
-
139
- ### 错误写法
140
- ```typescript
141
- const decoder = new TextDecoder(); // ERROR: Cannot find name 'TextDecoder'
142
- const str = decoder.decode(data);
143
- ```
144
-
145
- ### 正确写法
146
- ```typescript
147
- const bytes = new Uint8Array(data);
148
- let chunk = '';
149
- for (let i = 0; i < bytes.length; i++) {
150
- chunk += String.fromCharCode(bytes[i]);
151
- }
152
- ```
153
-
154
- ---
155
-
156
- ## Pattern 7: HTTP 组件事件名
157
-
158
- | 错误事件 | 正确事件 | 说明 |
159
- |---------|---------|------|
160
- | `request.on('requestEnd', ...)` | `request.on('dataEnd', ...)` | 请求结束事件 |
161
- | `request.on('error', ...)` | 改用 Promise 的 catch | HTTP 组件 error 事件签名不标准 |
162
-
163
- ---
164
-
165
- ## Pattern 8: GeminiService 等自定义类缺少成员
166
-
167
- ### 错误场景
168
- ```typescript
169
- class GeminiService {
170
- private async sendRequest(url: string, body: object): Promise<Object> {
171
- httpRequest.request(url, { extraData: JSON.stringify(body),
172
- connectTimeout: this.timeout, // ERROR: Property 'timeout' does not exist
173
- readTimeout: this.timeout
174
- });
175
- }
176
- // timeout 属性忘记声明
177
- }
178
- ```
179
-
180
- ### 正确 — 确保所有成员都在类体内声明
181
- ```typescript
182
- class GeminiService {
183
- private timeout: number = 30000; // 在类体内声明
184
- private async sendRequest(...) { ... }
185
- }
186
- ```
187
-
188
- ---
189
-
190
- ## Pattern 9: Button 不支持 emoji
191
-
192
- ### 错误写法
193
- ```typescript
194
- Button('X') // 有时 emoji 渲染异常
195
- Button('🗑')
196
- ```
197
-
198
- ### 正确写法
199
- ```typescript
200
- Button('Del') // 纯文本
201
- Button('Copy')
202
- Button('Back')
203
- ```
204
-
205
- ---
206
-
207
- ## 快速检查清单
208
-
209
- 遇到 ArkTS 编译错误时,按序检查:
210
-
211
- 1. throw → `throw new Error(String(x))`
212
- 2. 对象字面量作为参数 → 先赋值给显式类型变量
213
- 3. any / unknown → `Object` + `as Function` / `as SomeType`
214
- 4. // @ts-ignore → 禁止,必须用类型操作替代
215
- 5. ValuesBucket → 普通对象字面量 `{}`
216
- 6. margin { vertical } → `{ top, bottom }`
217
- 7. List 内 Divider → ListItem + border
218
- 8. TextDecoder → Uint8Array 遍历
219
- 9. `new SomeType()` 报错 → 检查是否是 type alias 而非 class
1
+ # ArkTS 严格模式确定性修复 Pattern
2
+ # 适用于: ArkTS 严格模式编译错误
3
+ # 触发场景: 编译报错 arkts-no-xxx 系列
4
+ # 经验来源: EinkBro 迁移 (2026-03-26)
5
+
6
+ ---
7
+
8
+ ## Pattern 1: throw 语句
9
+
10
+ ### 错误写法
11
+ ```typescript
12
+ throw err; // ERROR: arkts-limited-throw
13
+ throw 'error string'; // ERROR: arkts-limited-throw
14
+ throw unknownVariable; // ERROR: arkts-limited-throw
15
+ ```
16
+
17
+ ### 正确写法
18
+ ```typescript
19
+ throw new Error(String(error));
20
+ ```
21
+
22
+ ### 不需要修改的情况
23
+ ```typescript
24
+ throw new Error('specific message'); // OK - 已经是 Error 实例
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Pattern 2: 对象字面量作为参数 (arkts-no-untyped-obj-literals)
30
+
31
+ ### 错误写法
32
+ ```typescript
33
+ // ERROR: Object literal must correspond to some explicitly declared class or interface
34
+ const response = await this.sendRequest(url, { contents });
35
+ ```
36
+
37
+ ### 正确写法 — 先声明变量
38
+ ```typescript
39
+ interface GeminiRequestBody {
40
+ contents: GeminiContent[];
41
+ }
42
+
43
+ const requestBody: GeminiRequestBody = { contents };
44
+ const response = await this.sendRequest(url, requestBody);
45
+ ```
46
+
47
+ ### 内联参数场景
48
+ ```typescript
49
+ // 方法参数也是对象字面量,同样需要处理
50
+ httpRequest.request(url, {
51
+ method: http.RequestMethod.POST,
52
+ header: { 'Content-Type': 'application/json' },
53
+ extraData: JSON.stringify(body),
54
+ connectTimeout: 30000,
55
+ readTimeout: 30000
56
+ });
57
+ // ^ 这种场景 SDK 方法签名本身接受 object 类型,通常 OK
58
+ // 但自定义方法调用时必须用已声明接口的变量
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Pattern 3: Margin vertical 简写不支持
64
+
65
+ ### 错误写法
66
+ ```typescript
67
+ .margin({ vertical: 8 }); // ERROR: 'vertical' does not exist in type
68
+ ```
69
+
70
+ ### 正确写法
71
+ ```typescript
72
+ .margin({ top: 8, bottom: 8 });
73
+ ```
74
+
75
+ ### 常见场景
76
+ | 错误 | 正确 |
77
+ |------|------|
78
+ | `.margin({ vertical: 8 })` | `.margin({ top: 8, bottom: 8 })` |
79
+ | `.margin({ horizontal: 16 })` | `.margin({ left: 16, right: 16 })` |
80
+
81
+ ---
82
+
83
+ ## Pattern 4: List 内不能直接放 Divider
84
+
85
+ ### 错误写法
86
+ ```typescript
87
+ List() {
88
+ ForEach(items, (item) => {
89
+ ListItem() { /* ... */ }
90
+ })
91
+ Divider() // ERROR: List children must be ListItem only
92
+ }
93
+ ```
94
+
95
+ ### 正确写法 — 用 ListItem + border
96
+ ```typescript
97
+ List() {
98
+ ForEach(items, (item) => {
99
+ ListItem() {
100
+ Column() {
101
+ Text(item.name)
102
+ }
103
+ .width('100%')
104
+ .padding(12)
105
+ .border({ width: { bottom: 1 }, color: '#E0E0E0' }) // 替代 Divider 分隔线
106
+ }
107
+ })
108
+ }
109
+ ```
110
+
111
+ ### 另一种方案 — border 直接在 ListItem 上
112
+ ```typescript
113
+ ListItem() {
114
+ // content
115
+ }
116
+ .border({ width: { bottom: 1 }, color: '#E0E0E0' })
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Pattern 5: 数组字面量类型推断 (arkts-no-noninferrable-arr-literals)
122
+
123
+ ### 错误写法
124
+ ```typescript
125
+ const arr = [1, 2, 3].map(x => ({ val: x }));
126
+ // ERROR: Array literals must contain elements of only inferrable types
127
+ ```
128
+
129
+ ### 正确写法 — 显式类型
130
+ ```typescript
131
+ interface Item { val: number; }
132
+ const arr: Item[] = [1, 2, 3].map((x): Item => ({ val: x }));
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Pattern 6: TextDecoder 不存在
138
+
139
+ ### 错误写法
140
+ ```typescript
141
+ const decoder = new TextDecoder(); // ERROR: Cannot find name 'TextDecoder'
142
+ const str = decoder.decode(data);
143
+ ```
144
+
145
+ ### 正确写法
146
+ ```typescript
147
+ const bytes = new Uint8Array(data);
148
+ let chunk = '';
149
+ for (let i = 0; i < bytes.length; i++) {
150
+ chunk += String.fromCharCode(bytes[i]);
151
+ }
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Pattern 7: HTTP 组件事件名
157
+
158
+ | 错误事件 | 正确事件 | 说明 |
159
+ |---------|---------|------|
160
+ | `request.on('requestEnd', ...)` | `request.on('dataEnd', ...)` | 请求结束事件 |
161
+ | `request.on('error', ...)` | 改用 Promise 的 catch | HTTP 组件 error 事件签名不标准 |
162
+
163
+ ---
164
+
165
+ ## Pattern 8: GeminiService 等自定义类缺少成员
166
+
167
+ ### 错误场景
168
+ ```typescript
169
+ class GeminiService {
170
+ private async sendRequest(url: string, body: object): Promise<Object> {
171
+ httpRequest.request(url, { extraData: JSON.stringify(body),
172
+ connectTimeout: this.timeout, // ERROR: Property 'timeout' does not exist
173
+ readTimeout: this.timeout
174
+ });
175
+ }
176
+ // timeout 属性忘记声明
177
+ }
178
+ ```
179
+
180
+ ### 正确 — 确保所有成员都在类体内声明
181
+ ```typescript
182
+ class GeminiService {
183
+ private timeout: number = 30000; // 在类体内声明
184
+ private async sendRequest(...) { ... }
185
+ }
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Pattern 9: Button 不支持 emoji
191
+
192
+ ### 错误写法
193
+ ```typescript
194
+ Button('X') // 有时 emoji 渲染异常
195
+ Button('🗑')
196
+ ```
197
+
198
+ ### 正确写法
199
+ ```typescript
200
+ Button('Del') // 纯文本
201
+ Button('Copy')
202
+ Button('Back')
203
+ ```
204
+
205
+ ---
206
+
207
+ ## 快速检查清单
208
+
209
+ 遇到 ArkTS 编译错误时,按序检查:
210
+
211
+ 1. throw → `throw new Error(String(x))`
212
+ 2. 对象字面量作为参数 → 先赋值给显式类型变量
213
+ 3. any / unknown → `Object` + `as Function` / `as SomeType`
214
+ 4. // @ts-ignore → 禁止,必须用类型操作替代
215
+ 5. ValuesBucket → 普通对象字面量 `{}`
216
+ 6. margin { vertical } → `{ top, bottom }`
217
+ 7. List 内 Divider → ListItem + border
218
+ 8. TextDecoder → Uint8Array 遍历
219
+ 9. `new SomeType()` 报错 → 检查是否是 type alias 而非 class