メインコンテンツにスキップ
eLearner.app
TS TYPE GYMNASTICS ARENA

TSタイプアリーナ:タイプ体操

3 つの高度な型指定パズル (マップされた型、条件文、キーの再マッピング) を解決することで、TypeScript コンパイラーの制約を克服します。

TYPE CONSTRAINT

ユーティリティ タイプ「Pick<T, K>」のカスタム バージョンを作成します。型 'MyPick<T, K>' はオブジェクト型 T とキーの共用体 K を受け入れ、マップされた型とキー制約 (keyof T を拡張) を使用して T から要求されたプロパティのみを抽出する必要があります。

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.

エディターを読み込み中…