Comprehensive TypeScript guidance covering compiler configuration, advanced types, utility types, type guards, strict mode workflows, and documentation patterns; use when configuring tsconfig, designing complex generics, making illegal states unrepresentable, fixing type errors, or writing testable and maintainable type-safe APIs.
99
99%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Comprehensive TypeScript guidance covering compiler configuration, advanced types, utilities, type narrowing, best practices, and documentation patterns.
Use this skill when:
any and unsafe assertions?"This skill consolidates 5 original TypeScript skills (~3,372 lines) into a ~120-line navigation hub with on-demand reference loading:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| CRITICAL | Compiler & Configuration | Essential foundation | compiler- |
| CRITICAL | Best Practices & Patterns | Type-first workflow | practices- |
| HIGH | Advanced Types | Complex type logic | types-advanced- |
| HIGH | Built-in Utilities | Common transformations | utilities-builtin- |
| MEDIUM | Custom Utilities | Specialized types | utilities-custom- |
| MEDIUM | Type Narrowing | Runtime type guards | narrowing- |
| MEDIUM | Documentation | API docs & ADRs | docs- |
Read individual reference files for detailed guidance:
references/compiler-strict-mode.md
references/practices-type-first.md
references/types-advanced-conditional.md
references/utilities-builtin-partial.md
references/docs-jsdoc-patterns.mdEach reference file contains:
npx tsc --noEmit to confirm zero errors before proceedingnpx tsc --noEmit after each change — if errors persist, consult references/types-advanced-conditional.mdreferences/utilities-builtin-partial.mdnpx tsc --noEmit to confirm narrowing is recognised — if not, consult references/narrowing-guards.mdnpx typedoc --out docs src/index.ts and verify outputnpx tsc --noEmitnpx tsc --noEmit src/index.tsnpx typedoc --out docs src/index.tsrg -n "\\bany\\b|@ts-ignore| as " srcCommon TypeScript errors and their safe resolutions:
Caused by incompatible types being assigned without narrowing.
// BAD — forces an incompatible assignment
const id = getValue() as string;
// GOOD — narrow first, then assign
const raw = getValue();
if (typeof raw !== "string") throw new TypeError("Expected string");
const id = raw; // TypeScript now knows id: stringCaused by accessing a property without a null/undefined check.
// BAD — unsafe access
function getLength(arr: string[] | undefined) {
return arr.length; // error
}
// GOOD — guard before access
function getLength(arr: string[] | undefined): number {
if (arr === undefined) return 0;
return arr.length;
}Caused by missing type annotations under noImplicitAny.
// BAD — implicit any
function double(n) {
return n * 2;
}
// GOOD — explicit annotation
function double(n: number): number {
return n * 2;
}any as a default escape hatchWHY: any disables type checking and hides design bugs.
BAD:
function process(data: any) {
return data.value;
}GOOD:
function process<T extends { value: unknown }>(data: T) {
return data.value;
}WHY: assertions bypass compiler safety without runtime guarantees.
BAD:
const id = input as string;GOOD:
if (typeof input !== "string") throw new TypeError("Expected string");
const id = input;WHY: strict mode surfaces real defects early.
BAD: @ts-ignore, strict: false, or broad ignore patterns.
GOOD: adjust type model, narrow correctly, and keep strict checks enabled.
references