♢ TypeScript 类型体操 Playground
▶ 运行类型检查
清空
📝 类型定义
.ts
// ===== 泛型基础 ===== type Nullable<T> = T | null | undefined; // ===== 工具类型 ===== interface User { id: number; name: string; email: string; age?: number; } type PartialUser = Partial<User>; type RequiredUser = Required<User>; type UserName = Pick<User, 'id' | 'name'>; type UserWithoutEmail = Omit<User, 'email'>; // ===== 条件类型 ===== type IsString<T> = T extends string ? 'yes' : 'no'; // ===== 映射类型 ===== type Readonly<T> = { readonly [K in keyof T]: T[K] };
预设:
基础类型
工具类型
条件类型
高级体操
🔍 类型推导结果
就绪
⌨
编辑左侧代码后点击「运行类型检查」
📖 工具类型参考
内置