UNPKG

655 BTypeScriptView Raw
1/**
2 * Full credits to sindresorhus/type-fest
3 *
4 * https://github.com/sindresorhus/type-fest/blob/v0.8.1/source/set-required.d.ts
5 *
6 * Thank you!
7 */
8export type SetRequired<BaseType, Keys extends keyof BaseType = keyof BaseType> =
9 // Pick just the keys that are not required from the base type.
10 Pick<BaseType, Exclude<keyof BaseType, Keys>> &
11 // Pick the keys that should be required from the base type and make them required.
12 Required<Pick<BaseType, Keys>> extends
13 // If `InferredType` extends the previous, then for each key, use the inferred type key.
14 infer InferredType
15 ? {[KeyType in keyof InferredType]: InferredType[KeyType]}
16 : never;