lang-typescript

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<skill_doc> <trigger_keywords>
<skill_doc> <trigger_keywords>

Trigger Keywords

触发关键词

Activate this skill when the user mentions any of:
File Extensions:
.ts
,
.tsx
,
.mts
,
.cts
TypeScript Core: TypeScript, tsc, tsconfig, type inference, generics, satisfies, decorators, type guard, discriminated union, conditional types, mapped types, template literal types, infer keyword
SolidJS: SolidJS, Solid.js, createSignal, createStore, createMemo, createEffect, createResource,
<For>
,
<Show>
,
<Switch>
,
<Match>
,
<Index>
, onMount, onCleanup, fine-grained reactivity
TanStack: TanStack Start, TanStack Router, createFileRoute, createServerFn, useLoaderData, file-based routing, server functions, Vinxi
Validation: Valibot, v.object, v.string, v.pipe, v.safeParse, schema validation, type-safe validation
Testing: Vitest, Solid Testing Library, Playwright, @testing-library/solid, renderToString </trigger_keywords>
当用户提及以下任意内容时,激活本Skill:
文件扩展名:
.ts
,
.tsx
,
.mts
,
.cts
TypeScript核心内容: TypeScript, tsc, tsconfig, 类型推断, 泛型, satisfies, 装饰器, 类型守卫, 可辨识联合, 条件类型, 映射类型, 模板字面量类型, infer关键字
SolidJS: SolidJS, Solid.js, createSignal, createStore, createMemo, createEffect, createResource,
<For>
,
<Show>
,
<Switch>
,
<Match>
,
<Index>
, onMount, onCleanup, 细粒度响应式
TanStack: TanStack Start, TanStack Router, createFileRoute, createServerFn, useLoaderData, 基于文件的路由, 服务器函数, Vinxi
数据验证: Valibot, v.object, v.string, v.pipe, v.safeParse, Schema验证, 类型安全验证
测试: Vitest, Solid Testing Library, Playwright, @testing-library/solid, renderToString </trigger_keywords>

⛔ Forbidden Patterns

⛔ 禁止的模式

  1. NO
    any
    : Strictly forbidden. Use
    unknown
    if type is truly not known yet, or define a proper type/interface.
  2. NO
    @ts-ignore
    : Do not suppress errors. Fix them. Use
    @ts-expect-error
    ONLY if testing error cases explicitly.
  3. NO
    !
    (Non-null Assertion)
    : Avoid
    val!
    . Use optional chaining
    ?.
    or nullish coalescing
    ??
    .
  4. NO
    enum
    : Prefer union types (
    type Status = 'active' | 'inactive'
    ) or const objects. Enums add runtime overhead and behave unexpectedly.
  5. NO Default Exports: Prefer named exports to ensure consistent naming across the project and better tree-shaking.
  1. 禁止使用
    any
    类型
    : 严格禁止。如果类型确实未知,请使用
    unknown
    ,或者定义合适的类型/接口。
  2. 禁止使用
    @ts-ignore
    : 不要抑制错误,应修复错误。仅在明确测试错误场景时使用
    @ts-expect-error
  3. 禁止使用
    !
    (非空断言)
    : 避免使用
    val!
    。使用可选链
    ?.
    或空值合并运算符
    ??
    替代。
  4. 禁止使用
    enum
    : 优先使用联合类型(
    type Status = 'active' | 'inactive'
    )或常量对象。枚举会增加运行时开销,且行为不符合预期。
  5. 禁止默认导出: 优先使用命名导出,以确保项目内命名一致,并优化摇树优化效果。

🤖 Agent Tool Strategy

🤖 Agent工具策略

  1. Discovery: Check for
    justfile
    first. If it exists, use
    just -l
    to list recipes and prefer
    just
    commands over language-specific CLIs (npm, cargo, poetry, etc.). Then, read
    tsconfig.json
    to understand compiler options (strictness, paths, target).
  2. Linting: Check
    eslint.config.js
    or
    .eslintrc
    to align with project style.
  3. Type Checking: Use
    tsc --noEmit
    to verify type safety after changes if a build script isn't available.
  4. Testing: Run tests via
    bun test
    or
    vitest
    to ensure no regressions.
  5. File Operations: When creating files, ensure the extension matches the content (
    .tsx
    for JSX,
    .ts
    for logic).
  1. 发现阶段: 首先检查是否存在
    justfile
    。如果存在,使用
    just -l
    列出可用命令,并优先使用
    just
    命令而非特定语言的CLI(如npm、cargo、poetry等)。然后读取
    tsconfig.json
    以了解编译器选项(严格性、路径、目标版本)。
  2. 代码检查: 检查
    eslint.config.js
    .eslintrc
    以对齐项目代码风格。
  3. 类型检查: 如果没有构建脚本,在修改代码后使用
    tsc --noEmit
    验证类型安全性。
  4. 测试: 通过
    bun test
    vitest
    运行测试,确保没有回归问题。
  5. 文件操作: 创建文件时,确保扩展名与内容匹配(
    .tsx
    用于JSX代码,
    .ts
    用于逻辑代码)。

Quick Reference (30 seconds)

快速参考(30秒)

TypeScript 5.9+ Development Specialist - Modern TypeScript with SolidJS, TanStack Start, and type-safe API patterns.
Auto-Triggers:
.ts
,
.tsx
,
.mts
,
.cts
files, TypeScript configurations, SolidJS/TanStack Start projects
Core Stack:
  • TypeScript 5.9: Deferred module evaluation, decorators, satisfies operator
  • SolidJS: Fine-grained reactivity, signals, stores
  • TanStack Start: Full-stack framework with file-based routing, server functions
  • Valibot: Tree-shakable schema validation
  • Testing: Vitest, Solid Testing Library, Playwright

TypeScript 5.9+开发专家 - 结合SolidJS、TanStack Start和类型安全API模式的现代TypeScript开发。
自动触发条件:
.ts
,
.tsx
,
.mts
,
.cts
文件, TypeScript配置, SolidJS/TanStack Start项目
核心技术栈:
  • TypeScript 5.9: 延迟模块评估、装饰器、satisfies操作符
  • SolidJS: 细粒度响应式、信号、状态存储
  • TanStack Start: 基于文件路由的全栈框架、服务器函数
  • Valibot: 可摇树的Schema验证
  • 测试: Vitest, Solid Testing Library, Playwright

Implementation Guide (5 minutes)

实现指南(5分钟)

See patterns.md for detailed implementation patterns covering:
  • TypeScript 5.9 Key Features (Satisfies, Deferred Modules, Decorators)
  • SolidJS Patterns (Signals, Stores, Memos, Resources)
  • TanStack Start Patterns (Routes, Server Functions)
  • Valibot Schema Patterns
  • Advanced State Management
查看patterns.md获取详细的实现模式,涵盖:
  • TypeScript 5.9关键特性(Satisfies、延迟模块、装饰器)
  • SolidJS模式(信号、状态存储、Memo、资源)
  • TanStack Start模式(路由、服务器函数)
  • Valibot Schema模式
  • 高级状态管理

Quick Troubleshooting

快速故障排查

TypeScript Errors:
bash
bun run typecheck                    # Type check only
bunx tsc --generateTrace ./trace     # Performance trace
SolidJS/TanStack Start Issues:
bash
bun run dev                         # Development mode
bun run build                       # Check for build errors
rm -rf .vinxi .output && bun run dev  # Clear cache
Type Safety:
typescript
// Exhaustive check
function assertNever(x: never): never { throw new Error(`Unexpected: ${x}`); }

// Type guard
function isUser(v: unknown): v is User {
  return typeof v === "object" && v !== null && "id" in v;
}
  • patterns.md - Implementation patterns (SolidJS, TanStack, Valibot)
  • reference.md - Complete API reference, Context7 library mappings, advanced type patterns
  • examples.md - Production-ready code examples, full-stack patterns, testing templates
TypeScript错误:
bash
bun run typecheck                    # 仅类型检查
bunx tsc --generateTrace ./trace     # 性能追踪
SolidJS/TanStack Start问题:
bash
bun run dev                         # 开发模式
bun run build                       # 检查构建错误
rm -rf .vinxi .output && bun run dev  # 清除缓存
类型安全:
typescript
// 穷举检查
function assertNever(x: never): never { throw new Error(`Unexpected: ${x}`); }

// 类型守卫
function isUser(v: unknown): v is User {
  return typeof v === "object" && v !== null && "id" in v;
}
  • patterns.md - 实现模式(SolidJS、TanStack、Valibot)
  • reference.md - 完整API参考、Context7库映射、高级类型模式
  • examples.md - 生产级代码示例、全栈模式、测试模板

Context7 Integration

Context7集成

typescript
// TypeScript - mcp__context7__get_library_docs("/microsoft/TypeScript", "decorators satisfies", 1)
// SolidJS - mcp__context7__get_library_docs("/solidjs/solid", "createSignal createStore", 1)
// TanStack Start - mcp__context7__get_library_docs("/tanstack/start", "server-functions routing", 1)
// TanStack Router - mcp__context7__get_library_docs("/tanstack/router", "file-based-routing loaders", 1)
// Valibot - mcp__context7__get_library_docs("/fabian-hiller/valibot", "schema validation pipe", 1)

typescript
// TypeScript - mcp__context7__get_library_docs("/microsoft/TypeScript", "decorators satisfies", 1)
// SolidJS - mcp__context7__get_library_docs("/solidjs/solid", "createSignal createStore", 1)
// TanStack Start - mcp__context7__get_library_docs("/tanstack/start", "server-functions routing", 1)
// TanStack Router - mcp__context7__get_library_docs("/tanstack/router", "file-based-routing loaders", 1)
// Valibot - mcp__context7__get_library_docs("/fabian-hiller/valibot", "schema validation pipe", 1)

Works Well With

适配的Skill

  • moai-domain-frontend
    - UI components, styling patterns
  • moai-domain-backend
    - API design, database integration
  • moai-workflow-testing
    - Testing strategies and patterns
  • moai-foundation-quality
    - Code quality standards
  • moai-essentials-debug
    - Debugging TypeScript applications

  • moai-domain-frontend
    - UI组件、样式模式
  • moai-domain-backend
    - API设计、数据库集成
  • moai-workflow-testing
    - 测试策略与模式
  • moai-foundation-quality
    - 代码质量标准
  • moai-essentials-debug
    - TypeScript应用调试

Quick Troubleshooting

快速故障排查

TypeScript Errors:
bash
bun run typecheck                    # Type check only
bunx tsc --generateTrace ./trace     # Performance trace
SolidJS/TanStack Start Issues:
bash
bun run dev                         # Development mode
bun run build                       # Check for build errors
rm -rf .vinxi .output && bun run dev  # Clear cache
Type Safety:
typescript
// Exhaustive check
function assertNever(x: never): never { throw new Error(`Unexpected: ${x}`); }

// Type guard
function isUser(v: unknown): v is User {
  return typeof v === "object" && v !== null && "id" in v;
}
</skill_doc>
TypeScript错误:
bash
bun run typecheck                    # 仅类型检查
bunx tsc --generateTrace ./trace     # 性能追踪
SolidJS/TanStack Start问题:
bash
bun run dev                         # 开发模式
bun run build                       # 检查构建错误
rm -rf .vinxi .output && bun run dev  # 清除缓存
类型安全:
typescript
// 穷举检查
function assertNever(x: never): never { throw new Error(`Unexpected: ${x}`); }

// 类型守卫
function isUser(v: unknown): v is User {
  return typeof v === "object" && v !== null && "id" in v;
}
</skill_doc>