arkts_error_fixes
SKILL.md
ArkTS Error Fixes
This skill provides solutions for common ArkTS compilation errors and type mismatches encountered during HarmonyOS development.
Error Categories
| Category | Description |
|---|---|
| Notification API Type Errors | ContentType type incompatibility |
| Window API Type Errors | Type inference issues with window.getLastWindow |
| AppStorage Type Errors | Type inference errors with AppStorage.get() |
| Object Spread Type Errors | Type inference issues with object spread |
| @StorageLink Default Value Errors | Missing default values for @StorageLink properties |
| Object Literal Interface Errors | Object literals without explicit interfaces |
| Object Literal Type Errors | Using object literal types in return type annotations |
| Function Return Type Errors | Limited return type inference |
| Arrow Function Conversion Errors | Using function expressions instead of arrow functions |
| Color Property Errors | Non-existent Color properties |
| Interface Method Signature Errors | Method signature mismatches in object literals |
| AvoidArea Type Errors | Missing visible property in AvoidArea type |
Standalone Function this Errors |
Using this in standalone functions |
| TitleButtonRect Type Errors | Incorrect return type for getTitleButtonRect; accessing non-existent properties (left, top) |
| Catch Clause Type Errors | Type annotations in catch clauses |
| ESObject Type Errors | Restricted usage of ESObject type |
| Resource Conversion Errors | Resource to string/number conversion errors |
| Unused Variable Warnings | Declared but never used variables |
| IDataSource Type Errors | LazyForEach requires IDataSource implementation |
| Duplicate Entry Errors | Multiple @Entry decorators in same file |
| Possibly Null Errors | Object possibly null when accessing properties |
Quick Reference
| Error Type | Solution |
|---|---|
| Notification type error | Cast to number type |
| Window type error | Use callback pattern for getLastWindow |
| AppStorage type error | Use @StorageLink with LocalStorage or AppStorage.setAndLink (avoid setOrCreate) |
| Object spread error | Explicitly type objects |
| @StorageLink default value error | Add = undefined or specific default value |
| Object literal interface error | Define interface before using object literal |
| Object literal type error | Define interface and use it as return type |
| Function return type error | Add explicit return type annotation |
| Arrow function conversion error | Convert function to arrow function => |
| Color property error | Use hex color values instead of non-existent Color properties |
| Interface method signature error | Use property syntax method: () => {} instead of method syntax |
| AvoidArea type error | Add visible: false property to AvoidArea object |
Standalone function this error |
Pass context as parameter: function foo(context: Context) |
| TitleButtonRect type error | Use window.TitleButtonRect instead of window.Rect; only width and height properties available |
| Catch clause type error | Remove type annotation or use any/unknown |
| ESObject type error | Use ESModule or specific types instead of ESObject |
| Resource conversion error | Use Resource directly in UI components or use ResourceManager |
| Unused variable warning | Use console.info/hilog or delete unused variable |
| IDataSource type error | Implement IDataSource interface for LazyForEach |
| Duplicate Entry error | Remove extra @Entry, use @Component for child components |
| Possibly Null error | Use !== null check or optional chaining |
Detailed Error Solutions
Notification API Type Errors
Window API Type Errors
AppStorage Type Errors
Object Spread Type Errors
@StorageLink Default Value Errors
Object Literal Interface Errors
Object Literal Type Errors
Function Return Type Errors
Arrow Function Conversion Errors
Color Property Errors
Interface Method Signature Errors
AvoidArea Type Errors
Standalone Function this Errors
TitleButtonRect Type Errors
Catch Clause Type Errors
ESObject Type Errors
Resource Conversion Errors
Unused Variable Warnings
IDataSource Type Errors
Duplicate Entry Errors
Possibly Null Errors
Window Rect/Size Type Errors
Related Resources
Weekly Installs
3
Repository
open-deveco/ark…n-skillsGitHub Stars
3
First Seen
10 days ago
Installed on
cline3
gemini-cli3
github-copilot3
codex3
kimi-cli3
cursor3