From 7294f242b7f3ba9e0426b4aecbbf3eaa4fb51cd5 Mon Sep 17 00:00:00 2001 From: mzalevski Date: Sat, 4 Dec 2021 00:56:38 +0100 Subject: [PATCH] fix: omit false keys in getShape return type --- src/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 52c624f..6237137 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,8 +5,20 @@ type MakePropTypesBoolean = T extends object } : boolean; +type OmitFalseKeys = { + [K in keyof T as T[K] extends false ? never : K]: T[K]; +}; + type ParseReturnType = U extends object - ? Omit<{ [K in keyof U]: ParseReturnType], U[K]> }, "_"> + ? Omit< + { + [K in keyof OmitFalseKeys]: ParseReturnType< + T[Extract], + U[K] + >; + }, + "_" + > : T; export const getShape =