PickByType
提出詳細
type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K] }
提出日時 | 2023-09-15 13:09:51 |
---|---|
問題 | PickByType |
ユーザー | sankantsu |
ステータス | 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 }>>, ]