skills/development/typescript-advanced/SKILL.md
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.
npx skillsauth add pantheon-org/tekhne typescript-advancedInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.md
Each 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 --noEmit
npx tsc --noEmit src/index.ts
npx typedoc --out docs src/index.ts
rg -n "\\bany\\b|@ts-ignore| as " src
Common 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: string
Caused 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.
tools
A skill that produces warnings but no errors.
testing
A well-formed example skill for testing the validator.
development
A skill with code blocks and imperative instructions for testing content and contamination analysis.
tools