arkts-syntax-assistant
БесплатноБез исполняемых скриптовНе проверенArkTS syntax, migration, and optimization guide for HarmonyOS/OpenHarmony development. Triggers on: .ets files, ArkTS keywords, HarmonyOS/OpenHarmony context…
от SummerKaze★ 90 звёзд на GitHubОб этом скилле
ArkTS Syntax Assistant
Overview
ArkTS is the default development language for OpenHarmony applications. It builds upon TypeScript with enhanced static typing to improve program stability and performance.
Core Features
- Static Typing: All types determined at compile time, reducing runtime checks
- No Dynamic Object Layout: Object structure fixed at compile time, cannot be modified at runtime
- Restricted Operators: Some operator behaviors are restricted to encourage clearer code semantics
- No Structural Typing: Structural typing is currently not supported
Reference Documentation
| Scenario | Document |
|---|---|
| Syntax Learning | references/en/introduction-to-arkts.md |
| Quick Overview | references/en/arkts-get-started.md |
| TS Migration | references/en/typescript-to-arkts-migration-guide.md |
| Migration Background | references/en/arkts-migration-background.md |
| Performance | references/en/arkts-high-performance-programming.md |
| More Cases | references/en/arkts-more-cases.md |
Workflows
1. Syntax Questions
User Question -> Identify Question Type -> Consult Documentation -> Provide Code Example
Common Syntax Questions:
- Variable declaration -> Use
let/constwith explicit type or inference - Function definition -> Supports optional parameters, defaults, rest parameters, arrow functions
- Classes and interfaces -> Must initialize fields, supports inheritance and implementation
- Generics -> Supports constraints and default values
- Null safety -> Nullable types ((T | null)), non-null assertion ((!)), optional chaining ((?.))
2. TypeScript Migration
Identify TS Code -> Check Incompatible Features -> Consult Migration Rules -> Provide ArkTS Alternative
Key Migration Rules Quick Reference:
| TypeScript | ArkTS Alternative |
|---|---|
var x |
let x |
any/unknown |
Specific types |
{n: 42} object literal |
Define class/interface first |
[index: T]: U index signature |
Record<T, U> |
A & B intersection type |
interface C extends A, B |
function(){} function expression |
() => {} arrow function |
<Type>value type assertion |
value as Type |
Destructuring [a, b] = arr |
Individual access arr[0], arr[1] |
for..in |
for loop or for..of |
| Constructor parameter properties | Explicit field declaration |
3. Performance Optimization
Analyze Code -> Identify Performance Issues -> Consult Optimization Guide -> Provide Solutions
High-Performance Programming Key Points:
- Declarations: Use
constfor invariants; avoid mixing integer and float - Loops: Extract loop invariants; avoid numeric overflow
- Functions: Parameter passing preferred over closures; avoid optional parameters
- Arrays: Use TypedArray for numeric values; avoid sparse arrays and union type arrays
- Exceptions: Avoid throwing in loops; use return values instead
4. Compile Error Resolution
Get Error Message -> Search Migration Rules -> Find Related Case -> Provide Fix
Common Questions
Q: How to handle JSON.parse return value?
// Error
let data = JSON.parse(str);
// Correct
let data: Record<string, Object> = JSON.parse(str);
Q: How to define object types?
// TypeScript syntax (not supported in ArkTS)
type Person = { name: string, age: number }
// ArkTS syntax
interface Person {
name: string;
age: number;
}
// Using object literal
let p: Person = { name: 'John', age: 25 };
Q: How to replace globalThis?
// Error
globalThis.value = 'xxx';
// Use singleton pattern
export class GlobalContext {
private constructor() {}
private static instance: GlobalContext;
private _objects = new Map<string, Object>();
public static getContext(): GlobalContext {
if (!GlobalContext.instance) {
GlobalContext.instance = new GlobalContext();
}
return GlobalContext.instance;
}
getObject(key: string): Object | undefined {
return this._objects.get(key);
}
setObject(key: string, value: Object): void {
this._objects.set(key, value);
}
}
Q: How to handle error types in catch?
// Error
try {} catch (e: BusinessError) {}
// Correct
try {} catch (error) {
let e: BusinessError = error as BusinessError;
}
Q: How to use Record type?
// TypeScript index signature
function foo(data: { [key: string]: string }) {}
// ArkTS Record
function foo(data: Record<string, string>) {}
// Usage example
let map: Record<string, number> = {
'John': 25,
'Mary': 21,
};
Q: How to repla
Установить arkts-syntax-assistant в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл arkts-syntax-assistant?
ArkTS syntax, migration, and optimization guide for HarmonyOS/OpenHarmony development. Triggers on: .ets files, ArkTS keywords, HarmonyOS/OpenHarmony context, @ohos packages. Help with syntax reference, TypeScript migration, performance optimization, compile errors, state management, component development, and language-specific questions.
Как установить скилл arkts-syntax-assistant?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл arkts-syntax-assistant запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic