typescript-best-practices

Analyze, generate, and scaffold TypeScript code following type safety and architecture standards.

Updated Aug 15, 2025
One-click install
npx skills add https://github.com/yehezkieldio/topaz --skill typescript-best-practices-yehezkieldio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-best-practices
Source: https://github.com/yehezkieldio/topaz/tree/main/.agents/skills/typescript-best-practices
Command: npx skills add https://github.com/yehezkieldio/topaz --skill typescript-best-practices-yehezkieldio

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Writing consistent, type-safe TypeScript is hard to enforce across a codebase, and developers often ship code with any types, unsafe assertions, and poor error handling that cause runtime failures. ## Core Features & Use Cases - Static Code Analysis: Run scripts/analyze.ts with Deno to detect anti-patterns like any types, non-null assertions, @ts-ignore, eval() usage, and unsafe iteration, with severity-ranked reports and JSON output for CI. - Type Generation from JSON: Use scripts/generate-types.ts to convert JSON data or API responses into TypeScript interfaces or type aliases, with readonly and export options. - Module Scaffolding: Use scripts/scaffold-module.ts to create structured service, utility, component, or hook modules with optional test files. - Use Case: When refactoring a JavaScript module to TypeScript, apply the coding standards and quick-reference tables in SKILL.md, consult the references on advanced types and async patterns, then verify the result with the analyzer script. ## Quick Start Ask the AI to review your TypeScript file for type safety issues and apply the best practices from this skill, then run the analyze script on your src directory for a full report.

Frequently Asked Questions about typescript-best-practices

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

FAQPage Schema
How do I check TypeScript code for common anti-patterns?

Run the analyze script with Deno: `deno run --allow-read scripts/analyze.ts ./src --strict`. It detects `any` types, non-null assertions, `@ts-ignore`, `eval()` usage, and other issues, with severity-ranked output and optional JSON format for CI pipelines.

How to generate TypeScript types from a JSON API response?

Use the generate-types script: `deno run --allow-read scripts/generate-types.ts ./response.json --name ApiResponse --interface --readonly`. It infers nested object types, array element types, and supports stdin input for piping curl output directly.

What runtime is required to run the TypeScript analysis scripts?

The scripts require Deno, not Node.js. They use Deno-specific APIs like `Deno.readTextFile` and `Deno.stat`, and are invoked with `deno run --allow-read` (plus `--allow-write` for generation and scaffolding scripts).

Should I use 'any' or 'unknown' for uncertain types in TypeScript?

Use `unknown` instead of `any`. The `any` type disables type checking entirely, while `unknown` forces you to narrow the type with type guards before use, preserving compile-time safety.

When should I not use this TypeScript best practices skill?

Skip it for pure JavaScript work without TypeScript, runtime debugging sessions, and framework-specific patterns like React or Vue, which are better handled by dedicated framework skills.