typescript

Enforces idiomatic TypeScript and JavaScript coding patterns, type safety rules, and async conventions.

10|2|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/nrdxp/predicate --skill typescript-nrdxp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/nrdxp/predicate/tree/main/skills/typescript
Command: npx skills add https://github.com/nrdxp/predicate --skill typescript-nrdxp

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript and JavaScript codebases often accumulate inconsistent patterns: any leakage, mutation-heavy code, enum misuse, and callback-style async that hides errors. This Skill gives the AI a concrete, enforceable rulebook so generated and reviewed code follows modern idiomatic conventions instead of Java-in-TypeScript habits. ## Core Features & Use Cases - Type Safety Rules: Enforces strict: true, unknown over any, discriminated unions, satisfies, as const, branded types, and boundary validation for runtime data. - Async and Functional Patterns: Standardizes async/await, Promise.all/allSettled/race, AbortController cancellation, and declarative map/filter/reduce pipelines over imperative mutation. - Style and Anti-Pattern Guards: Covers naming conventions, const-by-default, ===, ?? over ||, named exports, #field privacy, and a table of anti-patterns with remedies. - Use Case: When asking the AI to refactor a legacy JavaScript module or review a pull request, it applies these rules to replace enums with as const objects, convert .then() chains to async/await, and eliminate any types with proper narrowing. ## Quick Start Ask the AI to review or write TypeScript code in your project and it will apply these idiomatic conventions automatically.

Frequently Asked Questions about typescript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write type-safe TypeScript without using any?

Use `unknown` instead of `any` and narrow explicitly with typeof or instanceof checks before accessing values. Annotate function parameters and return types at boundaries while letting TypeScript infer obvious local types.

Should I use TypeScript enums or as const objects?

Prefer `as const` objects over TypeScript enums because enums emit runtime JavaScript while `as const` preserves literal types with no runtime overhead. Derive the union type with `typeof` and `keyof` for the same compile-time safety.

What is the difference between Promise.all and Promise.allSettled?

Promise.all fails fast on the first rejection and is used when all operations must succeed. Promise.allSettled waits for every promise and reports each outcome, making it suitable when partial failure is acceptable.

Why should I avoid default exports in TypeScript?

Named exports enable compile-time reference checks and explicit dependency graphs, so broken imports are caught immediately by the IDE. Default exports permit arbitrary renaming at the import site, hiding mismatches; they are acceptable only for framework conventions like Next.js pages.

When should I use ?? instead of || for default values?

Use the nullish coalescing operator `??` for defaults because `||` incorrectly falls through on falsy values like 0, empty strings, and false. `??` only falls through on null or undefined, preserving legitimate falsy inputs.