"Configures modern TypeScript (4.9+ through 5.x) for maximum type safety with sustainable compile times. Use when designing type-safe configs/maps/APIs, enforcing strictness flags, improving TS build performance (incremental, project references), or setting up separate TS/ESLint configs for tests."
Resources
1Install
npx skillscat add git-fg/thecattoolkit/configuring-typescript Install via the SkillsCat registry.
This skill configures modern TypeScript (4.9+ to 5.x) to maximize type safety while keeping compile times sustainable. It addresses the need for strict type checking in configuration, API, and map designs, and improves build performance through incremental and project reference settings. Use it when creating type‑safe configs, APIs, or when stricter compiler flags and faster builds are required.
TypeScript Advanced Types
Modern TypeScript playbook for writing code that is correct, ergonomic, and fast enough.
Quick Reference
| Need | See |
|---|---|
Modern features (satisfies, const type params) |
Modern Features |
| Generics, conditional types, mapped types | Type-Level Toolbox |
| Config objects, event emitters, API clients | Practical Patterns |
| Test patterns, tsconfig templates | Tests & Configs |
| Compile-time optimization | Performance Playbook |
| Type testing, PR checklist | Type Testing |
When to Use
Use this skill when:
- Building type-safe configs/maps/APIs (feature flags, route tables, event maps)
- Designing type-safe APIs (HTTP clients, RPC layers, CLI command maps)
- Enforcing strictness beyond
"strict": true:noUncheckedIndexedAccessexactOptionalPropertyTypesverbatimModuleSyntax
- Improving compile times (incremental builds, project references)
- Setting up separate TS/ESLint configs for tests
Default Workflow
- Start with data shape and ownership — Is value internally constructed (safe) or external input (unsafe)?
- Choose the lightest typing tool —
satisfiesfor configs, mapped types for transformations,inferfor function inference - Lock strictness and hygiene — Enable
noUncheckedIndexedAccess,exactOptionalPropertyTypes, considerverbatimModuleSyntax - Keep builds fast — Enable
incremental, use project references in monorepos, measure with--extendedDiagnostics - Tests: strict where matters, pragmatic where not — Separate
tsconfig.test.json, ESLint overrides for test files only
Key Highlights
satisfies — Use Aggressively
Validates object shape without losing literal inference or widening to string/number.
type AppConfig = {
env: "dev" | "prod";
apiBaseUrl: string;
retries: number;
};
export const config = {
env: "dev",
apiBaseUrl: "https://api.example.com",
retries: 3,
} satisfies AppConfig;
// config.env is "dev" (literal), not "dev" | "prod"Strictness Beyond "strict": true
noUncheckedIndexedAccess — Adds undefined to indexed access:
const dict: Record<string, { id: string }> = {};
const x = dict["missing"]; // { id: string } | undefinedexactOptionalPropertyTypes — Optional ≠ undefined:
type UserPrefs = { theme?: "dark" | "light" };
const prefs: UserPrefs = {};
prefs.theme = "dark"; // ok
// prefs.theme = undefined; // errorverbatimModuleSyntax — Module hygiene:
import type { User } from "./types"; // type-only
import { createUser } from "./runtime"; // runtime (kept in output)Resources
See references/ for detailed guides on each topic.