← ClaudeAtlas

typescript-code-stylelisted

Load before writing or editing any TypeScript or JavaScript file (.ts, .tsx, .js, .jsx), the moment a task will create or modify such code and before the first edit. Covers strictness, style, nullability, immutability, and assertion-based error handling. The trigger is writing; a session that only reads code leaves it unloaded.
toverux/grimoire · ★ 1 · AI & Automation · score 77
Install: claude install-skill toverux/grimoire
# TypeScript Code Style ## First: Detect the Project's Assertion Helpers The narrowing rules below branch on whether the project ships the `nn()` / `ensure*()` assertion helpers. Detect this once, before your first edit: search the codebase for `nn(`, `nn.assert`, or `ensure` (ex. `ensureString`) as definitions or imports. - Helpers found: apply the "With `nn()` / `ensure*()` Helpers" section below. - Helpers absent: apply the "Without Helpers" section below. Every other section applies to every project. ## TypeScript Strictness - You are working with TypeScript's strictest settings. - Never ever use `any`. Create types if necessary, derive from existing types, etc. - Use `unknown` when the value is genuinely unknown. - Use TypeScript built-in utility types when applicable, and the `type-fest` npm package for more advanced ones. - In interfaces, use property-style over method-style method signatures; property-style function declarations allow stricter checking under `strictFunctionTypes`. Use method shorthand in object literals. ## Style - Use named function hoisting to place the more important functions at the top: the deeper a function sits in the call stack, the deeper it sits in the file. Apply the same to functions inside functions, with helpers at the very bottom. - Use template literals for strings containing English sentences, even without interpolations: they make single and double quotes inside the sentence painless. ## Nullability - Prefer `undefine