Skip to content
Back to skills

Writing Typescript

ASecurity

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.

  • 36 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 6, 2026
developmenttypescriptpythonrustgoreactnodetesting

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned September 29, 2026

npx -y skills add alexei-led/cc-thingz --skill writing-typescript --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Writing Typescript?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Writing Typescript
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alexei-led-writing-typescript-c1462998/badge)](https://www.skillsdirectory.com/skills/alexei-led-writing-typescript-c1462998)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
{"description":"Idiomatic TypeScript development. Use when writing TypeScript code, Node.js services, React apps, or TypeScript design advice. Emphasizes strict typing, boundary validation, composition, fast feedback, behavior tests, and project-configured tooling. NOT for Go, Python, Rust, plain HTML/CSS/JS, or server-rendered templates (use writing-web).","name":"writing-typescript"}
---

# 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`, and `noFallthroughCasesInSwitch`.
- 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 cast `await res.json()` to a domain type.
- Avoid `any`, `as` casts, 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 `never` check. Literal unions or `as const` arrays instead of new enums. `satisfies` for config maps.
- Result unions for recoverable failures callers must branch on; throw `Error` instances otherwise.
- Pass dependencies as parameters; no singletons or hidden module state. Thread `AbortSignal` through 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`. Type `children` as `ReactNode`.
- Derive state during render. Fix stale closures instead of suppressing exhaustive-deps.
- Add `memo`, `useMemo`, or `useCallback` only 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](references/testing.md): read when adding or changing tests, including React component tests.
- [linting.md](references/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.

Files in this skill

  • SKILL.md3.9 KB
  • references/linting.md2 KB
  • references/patterns.md2.7 KB
  • references/principles.md2.6 KB
  • references/react.md2.1 KB
  • references/testing.md3.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.