typescript
БесплатноБез исполняемых скриптовНе проверенTypeScript language. Covers types, generics, and advanced patterns. Use when writing type-safe JavaScript code. USE WHEN: user mentions "typescript", "types"…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
TypeScript Core Knowledge
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:typescriptfor comprehensive documentation.
Basic Types
// Primitives
const str: string = 'hello';
const num: number = 42;
const bool: boolean = true;
const arr: number[] = [1, 2, 3];
const tuple: [string, number] = ['hello', 42];
// Objects
interface User {
id: number;
name: string;
email?: string; // Optional
readonly createdAt: Date;
}
type Status = 'active' | 'inactive' | 'pending'; // Union
Generics
// Generic function
function identity<T>(arg: T): T {
return arg;
}
// Generic interface
interface Repository<T> {
find(id: string): Promise<T | null>;
findAll(): Promise<T[]>;
create(data: Omit<T, 'id'>): Promise<T>;
}
// Generic constraint
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
Utility Types
Partial<T> // All properties optional
Required<T> // All properties required
Pick<T, K> // Select properties
Omit<T, K> // Remove properties
Record<K, V> // Key-value map
Readonly<T> // All properties readonly
ReturnType<F> // Function return type
Parameters<F> // Function parameters
Awaited<T> // Unwrap Promise
Advanced Patterns
// Discriminated unions
type Result<T> =
| { success: true; data: T }
| { success: false; error: Error };
// Type guards
function isUser(obj: unknown): obj is User {
return typeof obj === 'object' && obj !== null && 'id' in obj;
}
// Mapped types
type Nullable<T> = { [K in keyof T]: T[K] | null };
// Template literals
type EventName = `on${Capitalize<string>}`;
Config (tsconfig.json)
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "bundler"
}
}
When NOT to Use This Skill
| Scenario | Use Instead |
|---|---|
| Plain JavaScript project | javascript skill |
| Node.js runtime internals | nodejs skill |
| React-specific types | frontend-react skill |
| Testing type assertions | testing-vitest or testing-jest skills |
| Type generation from schema | api-design-openapi or framework-specific skills |
Anti-Patterns
| Anti-Pattern | Why It's Bad | Correct Approach |
|---|---|---|
Using any everywhere |
Defeats type safety | Use unknown or proper types |
as type assertions |
Runtime errors possible | Type guards or proper typing |
| Large union types | Hard to maintain | Discriminated unions or branded types |
Mixing interface and type |
Inconsistent codebase | Choose one convention |
| Ignoring strictNullChecks | Hidden null/undefined bugs | Enable strict mode |
| Index signatures without bounds | Unsafe access | Use Record or Map with validation |
| Deep nesting in generics | Unreadable types | Extract intermediate types |
Quick Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| "Type 'X' is not assignable to type 'Y'" | Type mismatch | Check type definitions, use type guards |
| "Property 'x' does not exist on type" | Missing or wrong type | Add property or fix interface |
| "Cannot find module" | Missing types or path | Install @types or configure paths |
| "Object is possibly 'null'" | strictNullChecks enabled | Use optional chaining or null checks |
| "Type instantiation is excessively deep" | Complex generic recursion | Simplify types or add type bounds |
| "Index signature is missing" | Accessing dynamic keys | Use Record or add index signature |
| Build takes too long | Too many files, no incremental | Enable incremental, use project references |
Static Analysis & Linting
Official Rules References
| Tool | Rules Count | Documentation |
|---|---|---|
| ESLint | 200+ | https://eslint.org/docs/latest/rules/ |
| TypeScript-ESLint | 100+ | https://typescript-eslint.io/rules/ |
| Biome | 200+ | https://biomejs.dev/linter/rules/ |
| SonarJS | 422 | https://rules.sonarsource.com/javascript/ |
Key Rules to Enable
// eslint.config.js (ESLint 9+)
export default [
{
rules: {
// Prevent bugs
'no-unused-vars': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
// Code quality
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'complexity': ['warn', 10],
'max-depth': ['warn', 4],
}
}
];
Recommended Configs
| Tool | Config | Command |
|---|---|---|
| ESLint | @eslint/js recommended |
npm init @eslint/config |
| TypeScript-ESLint | strict-type-checked |
See ts-eslint docs |
| Biome | Default | npx @biomejs/biome init |
Production Read
Установить typescript в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditВложенные файлы
FAQ
Что делает скилл typescript?
TypeScript language. Covers types, generics, and advanced patterns. Use when writing type-safe JavaScript code. USE WHEN: user mentions "typescript", "types", "generics", asks about "type safety", "type errors", "tsconfig", "utility types", "type guards", "branded types" DO NOT USE FOR: reviewing existing TypeScript code - use `review/typescript`, which covers the defects `tsc` and typescript-eslint do not report DO NOT USE FOR: Plain JavaScript without types - use `javascript` skill instead DO NOT USE FOR: Node.js runtime - use `nodejs` skill instead DO NOT USE FOR: Framework-specific typing - use framework skills (React, Vue, etc.)
Как установить скилл typescript?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл typescript запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic