typescript-pro by jeffallan/claude-skills
npx skills add https://github.com/jeffallan/claude-skills --skill typescript-protsc --noEmit 以在继续之前捕获类型错误tsc --noEmit 以确认更改后零错误type-coverage 等工具确认类型覆盖率;验证所有公共 API 是否都有显式返回类型;重复步骤 3-4 直到所有检查通过根据上下文加载详细指导:
| 主题 | 参考 | 加载时机 |
|---|---|---|
| 高级类型 | references/advanced-types.md |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 泛型、条件类型、映射类型、模板字面量类型 |
| 类型守卫 | references/type-guards.md | 类型收窄、可辨识联合、断言函数 |
| 工具类型 | references/utility-types.md | Partial、Pick、Omit、Record、自定义工具类型 |
| 配置 | references/configuration.md | tsconfig 选项、严格模式、项目引用 |
| 模式 | references/patterns.md | 建造者模式、工厂模式、类型安全 API |
// Branded type for domain modeling
type Brand<T, B extends string> = T & { readonly __brand: B };
type UserId = Brand<string, "UserId">;
type OrderId = Brand<number, "OrderId">;
const toUserId = (id: string): UserId => id as UserId;
const toOrderId = (id: number): OrderId => id as OrderId;
// Usage — prevents accidental id mix-ups at compile time
function getOrder(userId: UserId, orderId: OrderId) { /* ... */ }
type LoadingState = { status: "loading" };
type SuccessState = { status: "success"; data: string[] };
type ErrorState = { status: "error"; error: Error };
type RequestState = LoadingState | SuccessState | ErrorState;
// Type predicate guard
function isSuccess(state: RequestState): state is SuccessState {
return state.status === "success";
}
// Exhaustive switch with discriminated union
function renderState(state: RequestState): string {
switch (state.status) {
case "loading": return "Loading…";
case "success": return state.data.join(", ");
case "error": return state.error.message;
default: {
const _exhaustive: never = state;
throw new Error(`Unhandled state: ${_exhaustive}`);
}
}
}
// Deep readonly — immutable nested objects
type DeepReadonly<T> = {
readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];
};
// Require exactly one of a set of keys
type RequireExactlyOne<T, Keys extends keyof T = keyof T> =
Pick<T, Exclude<keyof T, Keys>> &
{ [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, never>> }[Keys];
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true,
"isolatedModules": true,
"declaration": true,
"declarationMap": true,
"incremental": true,
"skipLibCheck": false
}
}
satisfies 运算符进行类型验证Annotated 模式anyas 断言as const 的常量对象)实现 TypeScript 功能时,请提供:
TypeScript 5.0+、泛型、条件类型、映射类型、模板字面量类型、可辨识联合、类型守卫、品牌类型、tRPC、项目引用、增量编译、声明文件、常量断言、satisfies 运算符
每周安装量
1.2K
代码仓库
GitHub 星标数
7.3K
首次出现
Jan 21, 2026
安全审计
安装于
opencode1.0K
gemini-cli982
codex960
github-copilot935
claude-code896
cursor888
tsc --noEmit to catch type errors before proceedingtsc --noEmit to confirm zero errors after changestype-coverage; validate that all public APIs have explicit return types; iterate on steps 3–4 until all checks passLoad detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| Advanced Types | references/advanced-types.md | Generics, conditional types, mapped types, template literals |
| Type Guards | references/type-guards.md | Type narrowing, discriminated unions, assertion functions |
| Utility Types | references/utility-types.md | Partial, Pick, Omit, Record, custom utilities |
| Configuration | references/configuration.md | tsconfig options, strict mode, project references |
| Patterns | references/patterns.md | Builder pattern, factory pattern, type-safe APIs |
// Branded type for domain modeling
type Brand<T, B extends string> = T & { readonly __brand: B };
type UserId = Brand<string, "UserId">;
type OrderId = Brand<number, "OrderId">;
const toUserId = (id: string): UserId => id as UserId;
const toOrderId = (id: number): OrderId => id as OrderId;
// Usage — prevents accidental id mix-ups at compile time
function getOrder(userId: UserId, orderId: OrderId) { /* ... */ }
type LoadingState = { status: "loading" };
type SuccessState = { status: "success"; data: string[] };
type ErrorState = { status: "error"; error: Error };
type RequestState = LoadingState | SuccessState | ErrorState;
// Type predicate guard
function isSuccess(state: RequestState): state is SuccessState {
return state.status === "success";
}
// Exhaustive switch with discriminated union
function renderState(state: RequestState): string {
switch (state.status) {
case "loading": return "Loading…";
case "success": return state.data.join(", ");
case "error": return state.error.message;
default: {
const _exhaustive: never = state;
throw new Error(`Unhandled state: ${_exhaustive}`);
}
}
}
// Deep readonly — immutable nested objects
type DeepReadonly<T> = {
readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];
};
// Require exactly one of a set of keys
type RequireExactlyOne<T, Keys extends keyof T = keyof T> =
Pick<T, Exclude<keyof T, Keys>> &
{ [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, never>> }[Keys];
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true,
"isolatedModules": true,
"declaration": true,
"declarationMap": true,
"incremental": true,
"skipLibCheck": false
}
}
satisfies operator for type validationAnnotated pattern with type predicatesany without justificationas assertions without necessityas const)When implementing TypeScript features, provide:
TypeScript 5.0+, generics, conditional types, mapped types, template literal types, discriminated unions, type guards, branded types, tRPC, project references, incremental compilation, declaration files, const assertions, satisfies operator
Weekly Installs
1.2K
Repository
GitHub Stars
7.3K
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode1.0K
gemini-cli982
codex960
github-copilot935
claude-code896
cursor888
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装