Type Challenges Judge

PickByType

提出詳細

type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K]; };
提出日時2023-05-22 14:16:45
問題PickByType
ユーザーmrsekut
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' interface Model { name: string count: number isReadonly: boolean isEnable: boolean } type cases = [ Expect<Equal<PickByType<Model, boolean>, { isReadonly: boolean; isEnable: boolean }>>, Expect<Equal<PickByType<Model, string>, { name: string }>>, Expect<Equal<PickByType<Model, number>, { count: number }>>, ]