Type Challenges Judge

PickByType

提出詳細

type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K] }
提出日時2023-08-12 13:11:37
問題PickByType
ユーザーtekihei2317
ステータス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 }>>, ]