Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

typescript-ops

БесплатноЗапускает вложенные скриптыНе проверен

TypeScript type system and ecosystem patterns. Use for: typescript, ts, type, generic, utility type, Partial, Pick, Omit, Record, Exclude, Extract…

0xDarkMatterот 0xDarkMatter★ 86 звёзд на GitHub

Об этом скилле

TypeScript Operations

Comprehensive TypeScript skill covering the type system, generics, and production patterns.

Ecosystem facts verified as of 2026-08-08 (TypeScript 7, Zod 4, Valibot 1).

Staleness check: python scripts/check-typescript-facts.py --offline asserts the catalogued version-bearing facts (TypeScript major, zod, valibot) are still named in the prose and the dated currency note above is present; run --live to confirm each package's npm major still matches the documented major. Catalog: assets/typescript-facts.json.

Type Narrowing Decision Tree

How to narrow a type?
│
├─ Primitive type check
│  └─ typeof: typeof x === "string"
│
├─ Instance check
│  └─ instanceof: x instanceof Date
│
├─ Property existence
│  └─ in: "email" in user
│
├─ Discriminated union
│  └─ switch on literal field: switch (event.type)
│
├─ Null/undefined check
│  └─ Truthiness: if (x) or if (x != null)
│
├─ Custom logic
│  └─ Type predicate: function isUser(x: unknown): x is User
│
└─ Assertion (you know better than TS)
   └─ as: value as string (escape hatch, avoid when possible)

Type Guard Example

interface Dog { bark(): void; breed: string }
interface Cat { meow(): void; color: string }

function isDog(pet: Dog | Cat): pet is Dog {
    return "bark" in pet;
}

function handlePet(pet: Dog | Cat) {
    if (isDog(pet)) {
        pet.bark(); // TS knows it's Dog here
    } else {
        pet.meow(); // TS knows it's Cat here
    }
}

Discriminated Unions

type Result<T> =
    | { status: "success"; data: T }
    | { status: "error"; error: string }
    | { status: "loading" };

function handle<T>(result: Result<T>) {
    switch (result.status) {
        case "success": return result.data;     // data is available
        case "error":   throw new Error(result.error); // error is available
        case "loading": return null;
    }
    // Exhaustiveness check: result is `never` here
    const _exhaustive: never = result;
}

Utility Types Cheat Sheet

Utility What It Does Example
Partial<T> All props optional Partial<User> for update payloads
Required<T> All props required Required<Config> for validated config
Readonly<T> All props readonly Readonly<State> for immutable state
Pick<T, K> Select specific props Pick<User, "id" | "name">
Omit<T, K> Remove specific props Omit<User, "password">
Record<K, V> Object with typed keys/values Record<string, number>
Exclude<U, E> Remove types from union Exclude<Status, "deleted">
Extract<U, E> Keep types from union Extract<Event, { type: "click" }>
NonNullable<T> Remove null/undefined NonNullable<string | null>
ReturnType<F> Function return type ReturnType<typeof fetchUser>
Parameters<F> Function params as tuple Parameters<typeof createUser>
Awaited<T> Unwrap Promise type Awaited<Promise<User>> = User

Generic Patterns

Constrained Generics

// Basic constraint
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
    return obj[key];
}

// Multiple constraints
function merge<T extends object, U extends object>(a: T, b: U): T & U {
    return { ...a, ...b };
}

// Default generic type
type ApiResponse<T = unknown> = {
    data: T;
    status: number;
};

Conditional Types

// Basic conditional
type IsString<T> = T extends string ? true : false;

// infer keyword - extract inner type
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
type UnwrapArray<T> = T extends (infer U)[] ? U : T;

// Distributive conditional (distributes over union)
type ToArray<T> = T extends any ? T[] : never;
// ToArray<string | number> = string[] | number[]

// Prevent distribution with wrapping
type ToArrayNonDist<T> = [T] extends [any] ? T[] : never;
// ToArrayNonDist<string | number> = (string | number)[]

Mapped Types

// Make all properties optional and nullable
type Nullable<T> = { [K in keyof T]: T[K] | null };

// Add prefix to keys
type Prefixed<T, P extends string> = {
    [K in keyof T as `${P}${Capitalize<string & K>}`]: T[K];
};
// Prefixed<{ name: string }, "get"> = { getName: string }

// Filter keys by value type
type StringKeys<T> = {
    [K in keyof T as T[K] extends string ? K : never]: T[K];
};

Deep dive: Load ./references/generics-patterns.md for advanced type-level programming, recursive types, template literal types.

Modern Language Features (TypeScript 5.x → 6.0)

Feature Since What It Gives You
satisfies operator 4.9 Check a value against a type without widening it
Standard (TC39) decorators 5.0 @decorator on classes/methods without experimentalDecorators
const type parameters 5.0 function f<const T>(x: T) infers literal types without as const a
Полный SKILL.md на GitHub

Установить typescript-ops в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Write
Bash

Вложенные файлы

assets/typescript-facts.jsonreferences/config-strict.mdreferences/ecosystem.mdreferences/generics-patterns.mdreferences/ts7-native-compiler.mdreferences/type-system.mdreferences/utility-types.mdscripts/check-typescript-facts.py

FAQ

Что делает скилл typescript-ops?

TypeScript type system and ecosystem patterns. Use for: typescript, ts, type, generic, utility type, Partial, Pick, Omit, Record, Exclude, Extract, ReturnType, Parameters, keyof, typeof, infer, mapped type, conditional type, template literal type, discriminated union, type guard, type assertion, type narrowing, tsconfig, strict mode, declaration file, zod, valibot, typescript 7, tsgo, native compiler.

Как установить скилл typescript-ops?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл typescript-ops запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить typescript-ops с