typescript-best-practices

Apply TypeScript best practices for configuration, typing, and async patterns.

280|36|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/flpbalada/my-opencode-config --skill typescript-best-practices-flpbalada
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-best-practices
Source: https://github.com/flpbalada/my-opencode-config/tree/main/skills/typescript-best-practices
Command: npx skills add https://github.com/flpbalada/my-opencode-config --skill typescript-best-practices-flpbalada

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript projects often suffer from inconsistent typing, scattered conventions, and maintenance burdens. This skill provides a structured set of best-practice guidelines to unify typing strategies, project configuration, and code organization, reducing bugs and improving readability.

Core Features & Use Cases

  • Project configuration guidance: adopt strict compiler settings and a clean tsconfig to minimize runtime errors and improve tooling.
  • Typing strategy guidance: choose between interface vs type, use type inference effectively, prefer unknown over any, and design robust public APIs.
  • Code organization and patterns: establish clear module structure, barrel exports, and consistent file naming to simplify navigation and testing.
  • Async patterns and error handling: apply safe async/await patterns, parallelize independent calls with Promise.all, and implement guard clauses.
  • Quality and performance tips: leverage type-only imports, discriminated unions, and avoid excessive type complexity to keep builds fast and readable.

Quick Start

  • Enable strict mode in tsconfig.json and adopt the recommended TypeScript configurations.
  • Audit a sample module to decide between interface and type, replace any with unknown, and apply proper null/undefined handling.
  • Refactor a utility module to use barrel exports and a clean module structure.

Frequently Asked Questions about typescript-best-practices

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

FAQPage Schema
What's the best way to configure tsconfig for a new TypeScript project?▼

The best way to configure a new TypeScript project is to enable strict mode in your tsconfig.json, which minimizes runtime errors and improves tooling capabilities across the codebase.

How do I choose between interface and type when defining typing strategies?▼

Choosing between interface and type for your typing strategies involves assessing your needs, using type inference effectively, preferring unknown over any, and designing robust public APIs.

How do I handle async errors safely in TypeScript?▼

To handle async errors safely in TypeScript, apply safe async/await patterns, parallelize independent calls with Promise.all, and implement guard clauses to manage exceptions cleanly.

What are the best practices for TypeScript code organization and module structure?▼

Best practices for TypeScript code organization include establishing clear module structures, utilizing barrel exports, and applying consistent file naming to simplify navigation and testing.

Why should I replace any with unknown in my TypeScript codebase?▼

You should replace any with unknown in your TypeScript codebase to enforce safer type checking, leveraging type guards effectively while designing robust public APIs to prevent runtime errors.

Do I need type-only imports to improve TypeScript build performance?▼

Yes, you need type-only imports to improve TypeScript build performance, alongside leveraging discriminated unions and avoiding excessive type complexity to keep builds fast and readable.