首页/ AI 技能 / @skilllib/skill-2117939930272411661
Skill站外收录 @skilllib/skill-2117939930272411661

best-practices

提供符合 TypeScript 语言特性的工程化编码规范,涵盖命名约定、函数定义、模块组织、异步处理、类设计与类型使用等核心实践,强调显式类型、不可变性、可维护性及静态检查友好性,适用于中大型前端与全栈项目。

0.0 (0) 16 次安装 原作者 编程导航
收录于 2026-01-22
软件开发 AI 技能

Skills.MD

# TypeScript Best Practices ## **Priority: P1 (OPERATIONAL)** ## Implementation Guidelines - **Naming**: Classes/Types=`PascalCase`, vars/funcs=`camelCase`, consts=`UPPER_SNAKE`. Prefix `I` only if needed. - **Functions**: Arrows for callbacks; regular for exports. Always type public API returns. - **Modules**: Named exports only. Import order: external → internal → relative. - **Async**: Use `async/await`, not raw Promises. `Promise.all()` for parallel. - **Classes**: Explicit access modifiers. Favor composition. Use `readonly`. - **Types**: Use `never` for exhaustiveness, `asserts` for runtime checks. - **Optional**: Use `?:`, not `| undefined`. - **Imports**: Use `import type` for tree-shaking. ## Anti-Patterns - **No Default Exports**: Use named exports. - **No Implicit Returns**: Specify return types. - **No Unused Variables**: Enable `noUnusedLocals`. - **No `require`**: Use ES6 `import`. - **No Empty Interfaces**: Use `type` or non-empty interface. - **Use any**: Never use `any`, use `unknown` only when necessary. ## Reference & Examples See [references/examples.md](references/examples.md) for code samples including: - Immutable Interfaces - Exhaustiveness Checking - Assertion Functions - Dependency Injection Patterns - Import Organization ## Related Topics language | tooling | security

评论 0

还没有评论,来抢沙发。