Skip to content

Instantly share code, notes, and snippets.

@semlinker
Created October 9, 2022 11:25
Show Gist options
  • Save semlinker/d7cb55bd134a4039d33e73a63aba2581 to your computer and use it in GitHub Desktop.
Save semlinker/d7cb55bd134a4039d33e73a63aba2581 to your computer and use it in GitHub Desktop.
From T, pick a set of properties whose type are not assignable to U.
type OmitByType<T, U> = {
[P in keyof T as T[P] extends U ? never : P]: T[P]
}
type OmitBoolean = OmitByType<{
name: string
count: number
isReadonly: boolean
isEnable: boolean
}, boolean> // { name: string; count: number }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment