plugins/smedjen/skills/typescript-modern/SKILL.md
Modern TypeScript — utility types, generics, discriminated unions, template literals, satisfies, and type-level programming. Covers narrowing strategy, generics vs overloads, utility type selection, and type safety rules.
npx skillsauth add hjemmesidekongen/ai typescript-modernInstall 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.
Patterns beyond standard generics and narrowing — TS 5.4+ features, branded types, module augmentation, and type-level testing.
Inferred type predicates (5.5): Filter functions returning x !== null auto-narrow without is guards.
NoInfer<T> (5.4): Blocks a parameter from contributing to inference. Use on fallback params: create<T>(value: T, fallback: NoInfer<T>).
Const type parameters (5.0+): <const T> infers literal types without as const at call sites. Use for config factories.
Isolated declarations (5.5): --isolatedDeclarations requires explicit return types on exports. Parallel .d.ts emit for monorepo packages.
Prevent domain confusion (UserId vs OrderId are both strings, but swapping is a bug):
type Brand<T, B> = T & { readonly __brand: B };
type UserId = Brand<string, 'UserId'>;
const toUserId = (s: string) => s as UserId; // single controlled cast point
Brand at creation, accept branded types in signatures. One as cast at the entry point is acceptable.
Extend third-party types with declare module in .d.ts files under types/. Only extend, never override — if you need to change a field type, patch the library instead.
// @ts-expect-error as assertion: next line must error or test fails. expectTypeOf (vitest) / expectType (tsd) for positive assertions. Run both in CI.
satisfies preserves narrowest inference while constraining. Pair with as const.unknown for untrusted input. any only at seams you intend to replace.as is a compiler promise — if wrong, runtime crashes. Prefer narrowing or satisfies.See references/process.md for conditional types, mapped types, infer, tsconfig options, and anti-patterns.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.