agentleFS
DunoDogeDunoDoge/OHOS-Skills/arkts-debug/SKILL.md

arkts-debug

Skill1 starsChanged 2 months agoMITView on GitHub

Use when fixing ArkTS / .ets compilation errors and type mismatches in HarmonyOS / OpenHarmony app development. Triggers include errors mentioning ContentType, AppStorage.get, @StorageLink, getLastWindow, AvoidArea, TitleButtonRect, IDataSource, ESObject, LazyForEach, duplicate @Entry, "Object literal must correspond to some explicitly declared class or interface", "Possibly null", "Standalone function uses this", "Indexed access is not supported", arkts-no-props-by-index, "Declaration merging is not supported", arkts-no-decl-merging, "Cannot find module", "Maximum call stack", "inferred type cannot be named", or any arkts-no-* rule reported by hvigor / ArkCompiler. Loads a curated catalog of common HarmonyOS build errors and their canonical fixes.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the task is general ArkTS authoring / migration / style (not a concrete error to fix), prefer arkts-helper instead.

    line 20
  2. Distinctive:

    Read both for the matched category before editing the user's code.

    line 50
  3. Distinctive:

    If the user's code has multiple errors, fix them one category at a time and re-check the build before moving on.

    line 56
  4. Distinctive:

    When you reply, cite the specific reference file you used, e.g.:

    line 60

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Harmony Error Fixes

This skill provides solutions for common ArkTS compilation errors and type mismatches encountered during HarmonyOS / OpenHarmony development. Each entry has a focused reference document under references/ and a minimal .ets example under assets/.

When to Use This Skill

Activate this skill whenever any of the following holds:

  • The user pastes an ArkTS / .ets compile error from DevEco Studio, hvigor, or ArkCompiler.
  • The error contains rule codes from the arkts-no-* family, or mentions any of: ContentType, AppStorage.get, @StorageLink, getLastWindow, AvoidArea, TitleButtonRect, IDataSource, ESObject, LazyForEach, duplicate @Entry, "Possibly 'null'", "Object literal must correspond to some explicitly declared class or interface", "Standalone function ... uses this", "Indexed access is not supported", arkts-no-props-by-index, "Declaration merging is not supported", arkts-no-decl-merging, "Cannot find module", "Maximum call stack", "inferred type cannot be named".
  • The user asks how to fix a HarmonyOS build failure or strict ArkTS type error.
  • You are reviewing .ets code and want to pre-empt the most common compile errors.

If the task is general ArkTS authoring / migration / style (not a concrete error to fix), prefer arkts-helper instead. Use both together when the user is migrating TS to ArkTS and hits compile errors.

Boundary with Other Skills

This skill covers "how to fix compilation errors", not "how to write code", "how to invoke build commands", or "how to write NDK code". When a fix task involves the following issues, cross-reference the corresponding skill:

Issue TypeCross-reference SkillBoundary
ArkTS syntax / migration / coding style (non-error scenarios)arkts-helperThis skill covers "how to fix errors"; arkts-helper covers "how to write compliant code to avoid errors"
Need to rebuild and verify after fixing codearkts-buildUse this skill to fix code, then use arkts-build's hvigorw commands to rebuild and confirm the error is resolved
NDK / C++ side compilation errorsarkts-ndk-devThis skill only covers ArkTS-side compilation errors; if errors come from C++ / CMake / Node-API layers (e.g. .so link failures, undefined symbols), use arkts-ndk-dev
Errors / API changes not covered by offline docsharmony-fetchIf the 28 error categories in this skill do not cover the current error (e.g. new arkts-no-* rules, deprecated APIs), use harmony-fetch to fetch the latest documentation from the Huawei developer portal
Code compiles but crashes at runtime (闪退/白屏/jscrash)arkts-crash-diagnosisThis skill covers compile-time errors; runtime crash diagnosis and faultlog analysis belong to arkts-crash-diagnosis
Understanding an existing project / config field meaningunderstand-hmos"What is this file / why is this config here" questions belong to understand-hmos
Creating a new project from scratchcreate-hmos-projectProject scaffolding belongs to create-hmos-project
Lite Wearable app fails at runtime on the Simulator (仿真器)lite-simulator-debugCompile-time errors belong to this skill; once the code compiles, running/debugging Lite Wearable apps on the DevEco Studio Simulator belongs to lite-simulator-debug

Workflow (follow strictly)

1. Identify the error category

Read the user's error message and map it to one row in the Error Categories table below. The mapping is based on the diagnostic text or the API/decorator that triggered it. If the error does not match any row, fall back to arkts-helper/references/04-ts-to-arkts-migration-rules.md for the underlying arkts-no-* rule.

2. Open the matching reference + asset

For each category there are two files:

  • references/<topic>.md - root cause, canonical fix, edge-case notes.
  • assets/<Topic>.ets - minimal before / after code that compiles cleanly.

Read both for the matched category before editing the user's code. Do not skim only the Quick Reference table.

3. Apply the canonical fix

Apply the fix exactly as documented. Do not silence errors with as any, // @ts-ignore, ESObject, or by deleting type annotations - these patterns are themselves flagged by ArkTS strict mode and will resurface elsewhere.

If the user's code has multiple errors, fix them one category at a time and re-check the build before moving on; one fix often unblocks or reshapes the next error.

4. Cite the reference

When you reply, cite the specific reference file you used, e.g.:

Fix per arkts-debug/references/possibly_null_errors.md.

Error Categories

CategoryDescription
Notification API Type ErrorsContentType type incompatibility
Window API Type ErrorsType inference issues with window.getLastWindow
AppStorage Type ErrorsType inference errors with AppStorage.get()
Object Spread Type ErrorsType inference issues with object spread
@StorageLink Default Value ErrorsMissing default values for @StorageLink properties
Object Literal Interface ErrorsObject literals without explicit interfaces
Object Literal Type ErrorsUsing object literal types in return type annotations
Function Return Type ErrorsLimited return type inference
Arrow Function Conversion ErrorsUsing function expressions instead of arrow functions
Color Property ErrorsNon-existent Color properties
Interface Method Signature ErrorsMethod signature mismatches in object literals
AvoidArea Type ErrorsMissing visible property in AvoidArea type
Standalone Function this ErrorsUsing this in standalone functions
TitleButtonRect Type ErrorsIncorrect return type for getTitleButtonRect; non-existent left/top
Catch Clause Type ErrorsType annotations in catch clauses
ESObject Type ErrorsRestricted usage of ESObject type
Resource Conversion ErrorsResource to string/number conversion errors
Unused Variable WarningsDeclared but never used variables
IDataSource Type ErrorsLazyForEach requires IDataSource implementation
Duplicate Entry ErrorsMultiple @Entry decorators in the same file
Possibly Null ErrorsObject possibly null when accessing properties
Window Rect/Size Type Errorswindow.Rect / window.Size shape mismatch
Indexed Access Errorsarkts-no-props-by-index — bracket notation property access
Declaration Merging Errorsarkts-no-decl-merging — duplicate declarations or namespace merging
Inferred Type Naming ErrorsExported symbol's inferred type cannot be named without internal reference
Array Type Inference ErrorsMissing element type in array declarations (e.g., [][])
Module Resolution ErrorsCannot find module or no exported member
Circular Import ErrorsCircular module dependencies causing stack overflow

Quick Reference

Error TypeSolution
Notification type errorCast to number type
Window type errorUse callback pattern for getLastWindow
AppStorage type errorUse @StorageLink with LocalStorage or AppStorage.setAndLink (avoid setOrCreate)
Object spread errorExplicitly type objects
@StorageLink default value errorAdd = undefined or a specific default value
Object literal interface errorDefine an interface before using the object literal
Object literal type errorDefine an interface and use it as the return type
Function return type errorAdd explicit return type annotation
Arrow function conversion errorConvert function to arrow function =>
Color property errorUse hex color values instead of non-existent Color properties
Interface method signature errorUse property syntax method: () => {} instead of method syntax
AvoidArea type errorAdd visible: false property to AvoidArea object
Standalone function this errorPass context as parameter: function foo(context: Context)
TitleButtonRect type errorUse window.TitleButtonRect; only width/height are available
Catch clause type errorRemove type annotation from the catch parameter
ESObject type errorUse a concrete type or ESModule instead of ESObject
Resource conversion errorUse Resource directly in UI or ResourceManager for runtime values
Unused variable warningUse the value or delete the declaration
IDataSource type errorImplement IDataSource for LazyForEach
Duplicate Entry errorRemove extra @Entry; use @Component for child components
Possibly Null errorAdd !== null check or use optional chaining
Window Rect/Size type errorUse the correct window.Rect / window.Size shape
Indexed access errorUse dot notation or Map instead of bracket notation
Declaration merging errorConsolidate into a single declaration or use extends
Inferred type naming errorAdd explicit return type annotation to exported symbols
Array type inference errorSpecify explicit element type (e.g., string[][] instead of [][])
Module resolution errorCheck oh-package.json5, import path, and case sensitivity
Circular import errorExtract shared types into a separate module

Detailed Error Solutions

Notification API Type Errors

  • Notification Type Error
  • Code Example

Window API Type Errors

  • Window Type Inference Error
  • Code Example

AppStorage Type Errors

  • AppStorage Type Error
  • Code Example

Object Spread Type Errors

  • Object Spread Type Error
  • Code Example

@StorageLink Default Value Errors

  • @StorageLink Default Value Error
  • Code Example

Object Literal Interface Errors

  • Object Literal Interface Error
  • Code Example

Object Literal Type Errors

  • Object Literal Type Error
  • Code Example

Function Return Type Errors

  • Function Return Type Error
  • Code Example

Arrow Function Conversion Errors

  • Arrow Function Conversion Error
  • Code Example

Color Property Errors

  • Color Property Error
  • Code Example

Interface Method Signature Errors

  • Interface Method Signature Error
  • Code Example

AvoidArea Type Errors

  • AvoidArea Type Error
  • Code Example

Standalone Function this Errors

  • Standalone Function this Error
  • Code Example

TitleButtonRect Type Errors

  • TitleButtonRect Type Error
  • Code Example

Catch Clause Type Errors

  • Catch Clause Type Error
  • Code Example

ESObject Type Errors

  • ESObject Type Error
  • Code Example

Resource Conversion Errors

  • Resource Conversion Error
  • Code Example

Unused Variable Warnings

  • Unused Variable Warning
  • Code Example

IDataSource Type Errors

  • IDataSource Type Error
  • Code Example

Duplicate Entry Errors

  • Duplicate Entry Error
  • Code Example

Possibly Null Errors

  • Possibly Null Error
  • Code Example

Window Rect/Size Type Errors

  • Window Rect/Size Type Error
  • Code Example

Indexed Access Errors

  • Indexed Access Error
  • Code Example

Declaration Merging Errors

  • Declaration Merging Error
  • Code Example

Inferred Type Naming Errors

  • Inferred Type Naming Error
  • Code Example

Array Type Inference Errors

  • Array Type Inference Error
  • Code Example

Module Resolution Errors

  • Module Resolution Error
  • Code Example

Circular Import Errors

  • Circular Import Error
  • Code Example

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.