Part of window type
Daisho Komiyama edited this page Nov 1, 2022
·
3 revisions
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>