-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Partial.ts
23 lines (19 loc) · 775 Bytes
/
Partial.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { UnionKeys } from '../union_keys.js'
import type { Omit } from './omit.js'
import type { Pick } from './pick.js'
/**
* An alternative `Partial<T>` type that works with `exactOptionalPropertyTypes`
*/
export type Partial<T> = { [P in keyof T]?: T[P] | undefined }
/**
* Apply `Partial<>` on the selected properties.
*/
export type PartialPick<T, U extends UnionKeys<T>> = T extends T ? Omit<T, U> & Partial<Pick<T, U>> : never
/**
* @deprecated replaced by `PartialOmit`
*/
export type PartialExcept<T, U extends UnionKeys<T>> = T extends T ? Pick<T, U> & Partial<Omit<T, U>> : never
/**
* Apply `Partial<>` on all not selected properties.
*/
export type PartialOmit<T, U extends UnionKeys<T>> = T extends T ? Pick<T, U> & Partial<Omit<T, U>> : never