TypeScript Development
Follow the repository's TypeScript version, tsconfig, package manager, framework, and test runner. In a monorepo, work from the nearest package.json and tsconfig.json and name the package you chose.
Defaults
- Never weaken compiler options to pass a check. New configs enable
strict,noUncheckedIndexedAccess,exactOptionalPropertyTypes,useUnknownInCatchVariables,noImplicitOverride, andnoFallthroughCasesInSwitch. - Treat HTTP responses, JSON, env, storage, form data, and SDK output as
unknown. Narrow at the boundary with the project's schema library or a small type guard; never castawait res.json()to a domain type. - Avoid
any,ascasts, non-null!, and broad index signatures unless a runtime check or an external type gap justifies them. - Discriminated unions for variants and async state, with an exhaustive
nevercheck. Literal unions oras constarrays instead of new enums.satisfiesfor config maps. - Result unions for recoverable failures callers must branch on; throw
Errorinstances otherwise. - Pass dependencies as parameters; no singletons or hidden module state. Thread
AbortSignalthrough work that can outlive its caller. - Ask before adding a schema, form, query, or state library the project does not already use.
React
- Plain function components, not
React.FC. TypechildrenasReactNode. - Derive state during render. Fix stale closures instead of suppressing exhaustive-deps.
- Add
memo,useMemo, oruseCallbackonly for measured cost or a real identity need. - Validate fetched data in the fetcher, not in render. Custom hooks throw when their provider is missing.
Tooling
Typecheck with the project script or tsc --noEmit. Use one formatter and one linter per file; the selection order is in linting.md.
References
- testing.md: read when adding or changing tests, including React component tests.
- linting.md: read when choosing a formatter or linter, changing lint config, or diagnosing slow lint.
Done when the relevant build/test/lint checks pass on what you changed, or you name each check that did not run and why.


