type-fest 4.18.2 → 4.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {IfNever} from './if-never';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
3
5
|
|
|
@@ -36,10 +38,10 @@ export type ConditionalKeys<Base, Condition> =
|
|
|
36
38
|
[Key in keyof Base]-?:
|
|
37
39
|
// Pick only keys with types extending the given `Condition` type.
|
|
38
40
|
Base[Key] extends Condition
|
|
39
|
-
// Retain this key
|
|
40
|
-
|
|
41
|
+
// Retain this key
|
|
42
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
43
|
+
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
|
|
41
44
|
// Discard this key since the condition fails.
|
|
42
45
|
: never;
|
|
43
|
-
|
|
44
46
|
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
45
47
|
}[keyof Base];
|