We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
isOptionalOf<T>
1 parent 5330ea4 commit a254afaCopy full SHA for a254afa
is.ts
@@ -390,9 +390,12 @@ export type OptionalPredicate<T> = Predicate<T | undefined> & {
390
export function isOptionalOf<T>(
391
pred: Predicate<T>,
392
): OptionalPredicate<T> {
393
- return Object.assign(isOneOf([isUndefined, pred]), {
394
- optional: true as const,
395
- });
+ return Object.assign(
+ (x: unknown): x is Predicate<T | undefined> => isUndefined(x) || pred(x),
+ {
396
+ optional: true as const,
397
+ },
398
+ ) as OptionalPredicate<T>;
399
}
400
401
export default {
0 commit comments