Skip to main content
← Gists
typescript Feb 19, 2026

PickByValue Utilities

Select keys by value type to build focused subsets.

PickByValue is useful when you want to extract only fields of a certain type.

Type

pick-by-value.ts
type PickByValue<T, V> = {
[K in keyof T as T[K] extends V ? K : never]: T[K]
}

type Model = {
id: string
name: string
createdAt: Date
active: boolean
}

type StringFields = PickByValue<Model, string>