typescript-coding-standards

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

TypeScript 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
AGENTS.md
, 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.
在前端应用、后端服务、worker 和共享库中编写、审查或重构 TypeScript 时,遵循这些约定。
首先阅读目标仓库的
AGENTS.md
、package scripts 以及 lint/test 配置。明确的本地要求优先于这些共享默认值。将改动控制在请求的范围内;现有违规问题不能成为进行无关的全仓库迁移的理由。

Guides

指南

Read the guides relevant to the change before editing.
GuideRead when
TypeScript contractsWriting or reviewing functions, arguments, types, or constants.
File naming and sizeCreating, renaming, or splitting files.
Comments and JSDocDocumenting functions, types, or non-obvious logic.
Modules and organizationChoosing exports, import boundaries, or where code belongs.
Runtime behaviorHandling errors, external data, service dependencies, or backend import boundaries.
React and Next.jsChanging components, callbacks, or hooks; read the Next.js section only in Next.js apps.
TestingDeciding whether a test is useful, adding coverage, or reviewing assertions.
Tooling and verificationSelecting 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 不要求采用其他仓库的框架、格式化工具或依赖项。