跳转到主要内容
eLearner.app
TS TYPE GYMNASTICS ARENA

TS Type Arena:类型体操

通过解决三个高级打字难题(映射类型、条件和键重新映射)来克服 TypeScript 编译器的限制。

TYPE CONSTRAINT

创建实用程序类型“Pick<T, K>”的自定义版本。您的类型“MyPick<T, K>”必须接受对象类型 T 和键 K 的并集,使用映射类型和键约束从 T 中仅提取请求的属性(扩展 T 的 key)。

Constraint Monitor
CONSTRAINT UNMET
interface User {
name: string;
age: number;
active: boolean;
}
MyPick<User, "name" | "active">
✗ Type does not satisfy constraints or uses any/never
✗ Type does not satisfy constraints or uses any/nevertsc v5.4.5

Stuck?

Learn the fundamental concepts in the TypeScript course to solve this challenge.

Static TypeScript Compiler

Write valid type definitions to satisfy type assertions.

正在加载编辑器...