typescript

Enforces TypeScript style and type-safety conventions when editing TS and TSX code.

74|11|Updated Jul 4, 2024
One-click install
npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill typescript-opensourceagi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/OpenSourceAGI/qwksearch-research-agent/tree/main/apps/qwk-in-lobe/.agents/skills/typescript
Command: npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill typescript-opensourceagi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Maintaining consistent TypeScript style and strict type safety across a large codebase is difficult, especially when deciding between interface vs type, avoiding any, structuring imports, and handling async IO correctly. ## Core Features & Use Cases - Type Safety Rules: Guides choices between interface and type, Record<PropertyKey, unknown> over any/object, and @ts-expect-error over @ts-ignore. - Async and Import Conventions: Enforces async/await over sync IO APIs, separate import type statements, and alphabetically sorted import specifiers. - Code Structure Standards: Promotes named exports, reuse of @lobechat/utils helpers, antd-style theming tokens, and safe logging practices. - Use Case: When refactoring a React component in a LobeHub project, apply this guide to fix implicit any types, convert .then() chains to async/await, and split type imports correctly. ## Quick Start Review my TypeScript file and fix any type-safety, import, or async pattern violations according to the project style guide.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I choose between interface and type in TypeScript?

Use interface for object shapes such as React props, and type for unions and intersections. Interfaces support declaration merging, which makes them preferable for extensible object contracts.

How should I write type-only imports in TypeScript?

Use separate import type statements rather than inline import { type X } syntax. When a module needs both type and value imports, keep them as two distinct statements with specifiers sorted alphabetically.

When is it acceptable to use sync fs APIs in Node.js?

Sync APIs are acceptable only inside synchronous contracts you do not control, such as legacy sync call chains or process.on('exit') callbacks. New IO code should use promise-based APIs like fs/promises with async/await.

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

Prefer @ts-expect-error because it fails if the suppressed error disappears, keeping suppressions honest. Use @ts-ignore only when necessary, and avoid casting with as any.

When should I use export default versus named exports?

Prefer named exports because they keep renames and IDE auto-imports in sync. Reserve export default for framework-required cases like Next.js pages, route handlers, React.lazy targets, and config files.