File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,14 @@ type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
27
27
@category Object
28
28
*/
29
29
export type SetRequired < BaseType , Keys extends keyof BaseType > =
30
- Simplify <
31
- BaseType &
32
- // Pick the keys that should be required from the base type and make them required.
33
- Required < Pick < BaseType , Keys > >
34
- > ;
30
+ // `extends unknown` is always going to be the case and is used to convert any
31
+ // union into a [distributive conditional
32
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
33
+ BaseType extends unknown
34
+ ? Simplify <
35
+ // Pick just the keys that are optional from the base type.
36
+ Except < BaseType , Keys > &
37
+ // Pick the keys that should be required from the base type and make them required.
38
+ Required < Pick < BaseType , Keys > >
39
+ >
40
+ : never ;
You can’t perform that action at this time.
0 commit comments