PickByType
提出詳細
type PickByType<T, U> = { [P in keyof T as T[P] extends U ? P : never]: T[P] }
提出日時 | 2024-09-11 10:54:05 |
---|---|
問題 | PickByType |
ユーザー | ookkoouu |
ステータス | 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 }>>, ]