skills/typescript-best-practices/SKILL.md
TypeScript conventions for this repo (no `any`, explicit return types, JSDoc, exactOptionalPropertyTypes, ambient types, import style). Use when authoring or editing any `.ts` or `.tsx` file, resolving TypeScript strictness errors, or fixing type-related lint failures. Do NOT use for React-specific typing patterns (see react-best-practices skill) or JSDoc-only changes (see code-comment-best-practices skill).
npx skillsauth add bkinsey808/songshare-effect typescript-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Requires: file-read, terminal (linting/testing). No network access needed.
Full reference: /docs/typescript-best-practices.md
.ts or .tsx file.npm run lint after meaningful TS changes.No any — use unknown + type guards instead.
→ full detail
Prefer type over interface — for object shapes, unions, and function signatures.
→ full detail
Explicit return types — always annotate function return types. → full detail
JSDoc on new/changed functions — concise, purpose-focused, no type annotations in JSDoc. → code-comment-best-practices skill
Keep JSDoc in sync — if you change params, props, or the behavior described by existing JSDoc, update the JSDoc in the same edit.
Ambient types — ReactElement is ambient (no import needed); ReactNode must be imported.
→ full detail
Destructure params in signature — destructure object parameters in the function signature, not the body.
exactOptionalPropertyTypes — use conditional spread ...(x === undefined ? {} : { x }) to thread optional props; never pass T | undefined where T is expected.
→ full detail
No redundant casts — prefer an explicit type annotation on the receiving variable over an inline as cast.
→ full detail
Set from optional arrays — new Set(optionalArray) needs no ?? [] fallback.
→ full detail
Type-only imports — import type { } for all-type imports; inline type keyword for mixed imports.
→ full detail
exactOptionalPropertyTypes: true are always on.no-null lint rule is active; use oxlint-disable-next-line no-null only when clearing nullable FK columns.as assertion with justification).npm run lint # lint (always from project root)
npm run test:unit # when behavior is non-trivial
lint-error-resolution.react-best-practices.code-comment-best-practices.tools
Zustand state management patterns for this project — store creation, selectors, Immer middleware, async actions with loading states, devtools, persist, and testing. Use when authoring or editing Zustand stores (use*Store files) or components that subscribe to stores. Do NOT use for React component structure or TypeScript-only utilities.
testing
How to write, update, or split skill files in this repo. Use when creating a new SKILL.md, updating an existing one, or deciding whether to put content in a skill vs. docs/.
development
Complete guide for testing React hooks — renderHook, Documentation by Harness, installStore, fixtures, subscription patterns, lint/compiler traps, and pre-completion checklist. Read docs/testing/unit-test-hook-best-practices.md for the full reference.
development
Vitest unit test authoring for this repo — setup, mocking, API handler testing, and common pitfalls for non-hook code. Use when the user asks to add, update, fix, or review unit tests for utilities, components, API handlers, or scripts. Do NOT use for React hook tests — load unit-test-hook-best-practices instead.