-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathunwrap-partial.d.ts
More file actions
33 lines (26 loc) · 787 Bytes
/
unwrap-partial.d.ts
File metadata and controls
33 lines (26 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
Revert the `Partial` modifier on an object type.
Use-case: Infer the underlying type `T` when only `Partial<T>` is available or the original type may not be directly accessible.
@example
```
import type {UnwrapPartial} from 'type-fest';
type Config = Partial<{
port: number;
host: string;
secure?: boolean;
}>;
type InitializedConfig = UnwrapPartial<Config>;
//=> {port: number; host: string; secure?: boolean}
```
Note: If the provided type isn’t of `Partial<T>`, `UnwrapPartial` has no effect on the original type.
@category Object
*/
export type UnwrapPartial<PartialObjectType> =
PartialObjectType extends Partial<infer ObjectType>
? (
Partial<ObjectType> extends PartialObjectType
? ObjectType
: PartialObjectType
)
: PartialObjectType;
export {};