Part of window type - kdaisho/Blog GitHub Wiki

type PickProperties<
  ValueType,
  Keys extends keyof ValueType
> = {
  [Key in Keys]: ValueType[Key]
}

type PartOfWindow = PickProperties<
  Window,
  "setTimeout" | "setInterval"
>

const win:PartOfWindow = window
win.document
// ^ tsc error

Above can be done with Pick<Type, Keys>

⚠️ **GitHub.com Fallback** ⚠️