typescript

Enforces TypeScript style and type safety rules when editing TS and TSX files.

Updated Jan 27, 2026
One-click install
npx skills add https://github.com/SmallAi-API/smaihub --skill typescript-smallai-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/SmallAi-API/smaihub/tree/main/.agents/skills/typescript
Command: npx skills add https://github.com/SmallAi-API/smaihub --skill typescript-smallai-api

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Inconsistent TypeScript code across a codebase leads to type safety gaps, sync/async debt, and duplicated utility helpers. This Skill provides a concrete style guide covering types, async patterns, imports, exports, reusability, and logging so edits to TS/TSX/MTS files follow one consistent standard. ## Core Features & Use Cases - Type Safety Rules: Enforces accurate typing practices such as preferring interface for object shapes, Record<PropertyKey, unknown> over any, and @ts-expect-error over @ts-ignore. - Async-First IO Guidance: Requires promise-based APIs like fs/promises for new IO code and defines the narrow cases where *Sync calls are acceptable. - Import and Export Conventions: Mandates named exports over default exports and lint-enforced import sorting with separate import type statements. - Use Case: When refactoring a module that reads files synchronously, apply this Skill to migrate to readFile from fs/promises, convert default exports to named exports, and replace hand-rolled object guards with helpers from @lobechat/utils/object. ## Quick Start Review my TypeScript file and rewrite it to follow the project's type safety, async, and import style rules.

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 code without explicit annotations?

Let TypeScript infer types where possible and only add explicit annotations when inference produces implicit any. Prefer Record<PropertyKey, unknown> over object or any, use interface for object shapes, and type for unions or intersections.

When should I use async/await instead of sync fs methods in Node.js?

Use async APIs like readFile from fs/promises for all new IO code, since sync-first designs force costly rewrites when concurrency is needed. Sync calls are only acceptable inside existing synchronous contracts you cannot change, such as process.on('exit') callbacks.

Should I use @ts-ignore or @ts-expect-error to suppress TypeScript errors?

Prefer @ts-expect-error over @ts-ignore because it fails the build once the underlying error is fixed, preventing stale suppressions. Use as any only as a last resort after both suppression comments.

Why prefer named exports over default exports in TypeScript?

Named exports keep refactor renames and IDE auto-imports in sync and avoid the re-naming drift caused by default imports. Reserve export default for framework-required cases like Next.js pages, React.lazy targets, and config files.

Can I use namespace for extending TypeScript module types?

No, prefer ES module augmentation with declare module over namespace-based extension patterns. For extensibility, expose a small mergeable interface at the source type and let each feature or plugin augment it locally.