{"enrichment":{"faq":[{"a":"typescript-idioms teaches that strict mode is your specification layer. Enable `strict: true` in tsconfig.json to enforce non-null checks, explicit `any` rejection, and sound property initialization. Use type guards (`typeof`, `instanceof`, custom predicates) instead of non-null assertions. Validate all external data\u2014especially API responses\u2014with Zod at boundaries. This prevents runtime surprises by catching type errors at compile time.","q":"What are typescript strict mode best practices?"},{"a":"typescript-idioms emphasizes that all HTTP calls must route through a centralized client for consistent auth and error handling. At that boundary, use Zod schemas to parse and validate responses before your code consumes them. Define a schema matching your API contract, call `.parse()` or `.safeParse()`, and reject invalid data. This ensures type safety isn't just a compile-time illusion\u2014runtime data is verified before it enters your type system.","q":"How do you implement runtime validation at API boundaries using Zod?"},{"a":"typescript-idioms stresses that `unknown` is the type-safe alternative to `any`. Both accept any value, but `unknown` requires you to narrow the type before use\u2014via type guards, `typeof` checks, or custom predicates\u2014forcing explicit validation. `any` bypasses all checks and defeats the type system. Use `unknown` for external data, function parameters you can't predict, and error objects. Reserve `any` only for legacy code or unavoidable third-party gaps.","q":"What is the difference between unknown vs any in typescript?"},{"a":"typescript-idioms teaches discriminated unions as the pattern for state machines. Define a union of state types, each with a literal `type` or `status` field that differs. TypeScript's type narrowing then automatically refines the union when you check that discriminant. For example, `type State = { type: 'idle' } | { type: 'loading'; request: Promise<Data> } | { type: 'error'; message: string }`. This makes illegal state transitions impossible at compile time.","q":"How do you build type-safe state machines with discriminated unions?"},{"a":"typescript-idioms advocates readonly to encode immutability in your types. Mark object properties and array types as `readonly` to prevent accidental mutations and signal intent. Use `as const` assertions on literals to infer the narrowest possible types. Immutability reduces bugs, makes concurrent code safer, and pairs well with functional patterns. Combined with strict mode and type guards, readonly enforces a discipline that catches mutation errors before runtime.","q":"What role do readonly and immutability patterns play in typescript?"},{"a":"typescript-idioms covers tooling integration: configure ESLint with `@typescript-eslint/parser` and `@typescript-eslint/recommended` rules to catch common mistakes. Enable Vitest with TypeScript support and mock external dependencies consistently. Use type checking in your CI pipeline alongside tests. This layered approach\u2014linting, type checking, unit tests, and centralized HTTP clients\u2014catches errors early and ensures your production code stays type-safe and maintainable.","q":"How should you configure ESLint and Vitest for typescript production code?"}],"shadow_tags":["type-safety","runtime-validation","strict-compilation","async-patterns","api-integration","immutability-enforcement","state-machine-design","null-safety","testing-doubles","code-quality"],"summary_rewrite":"Learn TypeScript's type system as your specification: enable strict mode, use type guards over casts, and validate all external data with Zod. This skill covers discriminated unions for state machines, immutability patterns, null safety, and the critical rule that all HTTP calls route through a centralized client for consistent auth and error handling."},"files":[{"bytes":10565,"path":".agents/skills/typescript-idioms/SKILL.md","sha256":"8d0e463ef3361cb3e88c59e57eab33cba00fa1dc9154607e95522fdd45acae72","url":"https://skillfed.io/files/irahardianto/awesome-agv/typescript-idioms/70f7ed2f/SKILL.md"}],"id":"irahardianto/awesome-agv/typescript-idioms","links":{"html":"https://skillfed.io/irahardianto/awesome-agv/typescript-idioms","md":"https://skillfed.io/irahardianto/awesome-agv/typescript-idioms.md","repo":"https://github.com/irahardianto/awesome-agv"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":48,"language":"JavaScript","last_updated":"2026-07-17","license":"MIT","name":"typescript-idioms","publisher":"irahardianto","stars":150},"relations":{"similar":[{"id":"irahardianto/awesome-agv/javascript-idioms"},{"id":"irahardianto/awesome-agv/hono-idioms"},{"id":"irahardianto/awesome-agv/vue-idioms"},{"id":"irahardianto/awesome-agv/angular-idioms"},{"id":"irahardianto/awesome-agv/nextjs-idioms"},{"id":"irahardianto/awesome-agv/php-idioms"},{"id":"irahardianto/awesome-agv/python-idioms"},{"id":"oakoss/agent-skills/typescript-patterns"},{"id":"irahardianto/awesome-agv/react-idioms"},{"id":"irahardianto/awesome-agv/csharp-idioms"}]},"slug":{"owner":"irahardianto","repo":"awesome-agv","skill":"typescript-idioms"},"version":"70f7ed2f"}
