programming-typescript
Guides the procedure for writing or changing TypeScript: loading the TypeScript standard first, driving each increment test-first, finding which rule a decision falls under, and confirming the gates before handing off.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- programming-typescript
- description
- Guides the procedure for writing or changing TypeScript: loading the TypeScript standard first, driving each increment test-first, finding which rule a decision falls under, and confirming the gates before handing off.
- when_to_use
- Use when writing, changing, or reviewing TypeScript code, before the first edit, alongside the language-agnostic application skill.
- compatibility
- Requires a TypeScript project with type check, lint, format, and unit test targets.
03 SKILL.md 正文
Programming TypeScript
TypeScript Standards owns every TypeScript rule, strict typing included. This skill restates none of them. It carries the procedure for applying that standard, and the judgement of noticing which rule a decision falls under. developing-applications covers the language-agnostic judgement, and Red, Green, Refactor owns the test-first cycle.
Before the First Edit
- Read the standard. Read TypeScript Standards in full, plus React Standards or Next.js Standards when the code uses them.
- Compare the project's configuration with it. A relaxed compiler option or a lint rule switched off is a finding to raise, not a baseline to copy into new code.
- Read the tests that cover the code before interpreting or changing it.
- List the increments, each one observable behaviour, simplest first, including every expected failure path.
Drive Each Increment Test-First
Run each increment through Red, Green, Refactor at the narrowest target that can prove it, usually a unit test with its operating-system-facing dependencies injected. Run the type check as part of each green, not only at the end: a type error discovered after several cycles tends to force a redesign of work already written.
When the compiler rejects a change, fix the code. The standard lists what never silences a type error, and reaching for one of those means the design, not the checker, needs attention.
Notice Which Rule Applies
These moments recur. Each points at the part of the standard that decides it:
| While writing, you meet | Apply, in TypeScript Standards |
|---|---|
| data arriving from a request, file, storage, or the environment | Typing Rules, on validation |
| a value whose shape is not known yet | Typing Rules, on any |
| two flags or optional fields that must never be set together | Typing Rules, on unions |
| two identifiers or quantities of the same primitive that must not mix | Typing Rules, on branded types |
| a call that can fail during normal operation | Expected Failures Are Returned |
| a promise started without being awaited or returned | Expected Failures Are Returned |
| a business decision taking shape inside an effectful function | Typing Rules, on code shape |
To decide between a returned failure and an exception, ask whether a caller in normal operation would need to handle it. If it would, the failure is expected, and it gets its own test.
Before Handing Off
- The type check, lint, and format gates pass, and then the fast gate from Quality Gates.
- Every increment carries its red, green, and refactor records.
- The diff has been read once against the Typing Rules section, looking for what no linter sees, such as a failure thrown where callers should expect it.
- No compiler option, lint rule, or coverage exclusion was relaxed to let the change pass.
04 同仓库更多 Skills
writing-browser-e2e-tests
Guides writing browser end-to-end tests that find elements as users do, wait on what the action produced, keep page knowledge in page objects, organize one feature per file, and run scenario-backed suites from generated specs.
usability-heuristic-evaluation
Guides judging a running interface as a first-time user would, without its specifications: citing a named principle for every finding, walking each task step, reading labels and addresses for scent, and rating severity.
tooling-nx
Guides Nx workspace work under the Nx standard: selecting projects by the graph, adding a target only where a capability exists, tracing a stale cached pass to its missing input, and answering a module-boundary finding.
programming-typescript
Guides the procedure for writing or changing TypeScript: loading the TypeScript standard first, driving each increment test-first, finding which rule a decision falls under, and confirming the gates before handing off.
programming-shell
Guides shell work under the shell standards: checking the declared dialect first, deciding whether logic belongs in shell at all, tracing where exit-on-error does not reach, and testing the script as its callers run it.
programming-javascript
Guides JavaScript work under the JavaScript standard: confirming the file is type-checked, typing through JSDoc, validating input the checker cannot see, and noticing floating promises and swallowed errors before handing off.