Skip to content
Back to skills

Typescript Strict

ASecurity

Write and refactor TypeScript under strict compiler settings without escape hatches

  • 5 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 30, 2026
developmenttypescriptgo

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add AdityaaaTiwari/ANVIL --skill typescript-strict --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Typescript Strict?

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

Security grade badge for Typescript Strict
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adityaaatiwari-typescript-strict/badge)](https://www.skillsdirectory.com/skills/adityaaatiwari-typescript-strict)

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
---
name: typescript-strict
description: Write and refactor TypeScript under strict compiler settings without escape hatches
---

<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->

# TypeScript under strict mode

Use when writing or changing TypeScript, or when type errors block a change.

## Ground rules
- Read `tsconfig.json` first. Respect `strict`, `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes` if they are on; never turn them off to make an error go away.
- No new `any`, `as unknown as T`, non-null `!` on values you have not checked, or `// @ts-ignore`. If you truly need an escape hatch, use `// @ts-expect-error <reason>` so it fails when it is no longer needed.
- Model data at the boundary: parse unknown input (`JSON.parse`, request bodies, env vars, files) with a schema (zod, valibot) or a hand-written type guard, then work with the narrowed type.

## Patterns that keep types honest
- **Discriminated unions** for state: `{ status: "ok"; value: T } | { status: "error"; error: E }`. Switch on the tag and add `const _exhaustive: never = state` in the default branch.
- **`satisfies`** to check an object literal against a type without widening it: `const routes = {...} satisfies Record<string, Route>`.
- **Branded IDs** when two strings must not be mixed: `type UserId = string & { readonly __brand: "UserId" }`.
- **`readonly`** arrays and properties for data you do not mutate.
- **Index access**: with `noUncheckedIndexedAccess`, `arr[0]` is `T | undefined`. Handle it (`const first = arr[0]; if (!first) return;`) instead of asserting.
- **Optional vs undefined**: with `exactOptionalPropertyTypes`, `{ a?: string }` cannot be assigned `{ a: undefined }`. Build objects with conditional spreads: `{ ...(a ? { a } : {}) }`.
- Prefer `unknown` in `catch (error)` and narrow with `error instanceof Error`.

## Verify
1. `npx tsc --noEmit -p tsconfig.json` (or the project's `typecheck` script) with zero new errors.
2. Search your diff for `any`, ` as `, `!.`, `@ts-ignore` and justify each remaining one.
3. Run the tests that cover the changed module.

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.

View all in development →

Comments

Loading comments…

Newsletter

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