Skip to content

Commit

Permalink
fix: omit false keys in getShape return type
Browse files Browse the repository at this point in the history
  • Loading branch information
mzalevski committed Dec 3, 2021
1 parent 42ab6ce commit 7294f24
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ type MakePropTypesBoolean<T, A = T> = T extends object
}
: boolean;

type OmitFalseKeys<T> = {
[K in keyof T as T[K] extends false ? never : K]: T[K];
};

type ParseReturnType<T, U> = U extends object
? Omit<{ [K in keyof U]: ParseReturnType<T[Extract<K, keyof T>], U[K]> }, "_">
? Omit<
{
[K in keyof OmitFalseKeys<U>]: ParseReturnType<
T[Extract<K, keyof T>],
U[K]
>;
},
"_"
>
: T;

export const getShape =
Expand Down

0 comments on commit 7294f24

Please sign in to comment.