Agent Skills
› TangleML/tangle-ui
› typescript-standards
typescript-standards
GitHub提供TypeScript编码规范,涵盖严格类型、避免不安全断言、API数据定义及命名约定。用于指导编写符合项目标准的TypeScript代码和类型定义。
Trigger Scenarios
编写TypeScript代码
定义类型
处理类型安全
Install
npx skills add TangleML/tangle-ui --skill typescript-standards -g -y
SKILL.md
Frontmatter
{
"name": "typescript-standards",
"description": "TypeScript coding standards for this project. Use when writing TypeScript code, defining types, or working with type safety."
}
TypeScript Standards
Core Rules
- Use strict TypeScript with proper typing
- Prefer explicit types over
any(only useanywhen absolutely necessary) - Use
interfacefor object shapes,typefor unions/primitives - Follow existing patterns for type definitions in
src/types/
Avoid Unsafe Type Casting
Don't use type assertions (as) unless absolutely necessary. Instead prefer:
- Type guards and runtime validation
- Proper typing from the source
- Union types and type narrowing
- Schema validation libraries (e.g., zod) for external data
// Bad
const something: string = myjson as string;
// Good - use type guards or validate the data
function isString(value: unknown): value is string {
return typeof value === "string";
}
API & Data Types
- Use the generated API client in
src/api/ - Prefer domain types: Use types from
src/utils/componentSpec.ts,src/types/, etc. for core business logic - Use generated API types: Only use
src/api/types.gen.tswhen directly interfacing with APIs or when domain types don't exist - Follow existing service patterns in
src/services/ - Use proper error handling with try/catch
Naming Conventions
- Components: PascalCase
- Files: PascalCase for components, camelCase for utilities
- Variables/functions: camelCase
- Constants: SCREAMING_SNAKE_CASE
- Types/Interfaces: PascalCase
- Directories: Follow the existing convention in the surrounding directory. The codebase uses both camelCase and PascalCase for folders — match what's already there
Version History
- d7768e8 Current 2026-09-02 20:59


