typescript-coding-standards
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTypeScript Coding Standards
TypeScript 编码规范
Apply these conventions when writing, reviewing, or refactoring TypeScript in
frontend apps, backend services, workers, and shared libraries.
Read the target repository's , package scripts, and lint/test
configuration first. Explicit local requirements take precedence over these
shared defaults. Keep changes within the requested scope; existing violations
do not justify an unrelated repository-wide migration.
AGENTS.md在前端应用、后端服务、worker 和共享库中编写、审查或重构 TypeScript 时,遵循这些约定。
首先阅读目标仓库的 、package scripts 以及 lint/test 配置。明确的本地要求优先于这些共享默认值。将改动控制在请求的范围内;现有违规问题不能成为进行无关的全仓库迁移的理由。
AGENTS.mdGuides
指南
Read the guides relevant to the change before editing.
| Guide | Read when |
|---|---|
| TypeScript contracts | Writing or reviewing functions, arguments, types, or constants. |
| File naming and size | Creating, renaming, or splitting files. |
| Comments and JSDoc | Documenting functions, types, or non-obvious logic. |
| Modules and organization | Choosing exports, import boundaries, or where code belongs. |
| Runtime behavior | Handling errors, external data, service dependencies, or backend import boundaries. |
| React and Next.js | Changing components, callbacks, or hooks; read the Next.js section only in Next.js apps. |
| Testing | Deciding whether a test is useful, adding coverage, or reviewing assertions. |
| Tooling and verification | Selecting tools or validating a code change. |
For backend-only work, skip the React guide. Use the consumer's existing tooling
and runtime conventions; the skill does not require adopting another repo's
framework, formatter, or dependencies.
编辑前,阅读与本次改动相关的指南。
| 指南 | 阅读时机 |
|---|---|
| TypeScript 契约 | 编写或审查函数、参数、类型或常量时。 |
| 文件命名与大小 | 创建、重命名或拆分文件时。 |
| 注释与 JSDoc | 为函数、类型或不明显的逻辑编写文档时。 |
| 模块与组织 | 选择导出方式、导入边界或确定代码归属位置时。 |
| 运行时行为 | 处理错误、外部数据、服务依赖或后端导入边界时。 |
| React 与 Next.js | 修改组件、回调或 hooks 时;仅在 Next.js 应用中阅读 Next.js 部分。 |
| 测试 | 判断测试是否必要、添加测试覆盖或审查断言时。 |
| 工具与验证 | 选择工具或验证代码改动时。 |
对于仅涉及后端的工作,请跳过 React 指南。使用消费方现有的工具链和运行时约定;本 skill 不要求采用其他仓库的框架、格式化工具或依赖项。