Skip to content

Commit

Permalink
fix: ensure DeepKey type handle optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
arimariojesus committed Oct 9, 2022
1 parent 3a7b96e commit f5aa11b
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
type ValidValues =
| string
| number
| Record<string, any>
| Array<any>
| undefined
| null;
type ValidValues = string | number | object | Array<any> | undefined | null;

export type DeepKey<
T extends Record<string, any>,
Expand All @@ -15,7 +9,7 @@ export type DeepKey<
: never
: K extends `${infer TKey}.${infer Rest}`
? T[TKey] extends ValidValues
? DeepKey<T[TKey], Rest> extends never
? DeepKey<Exclude<T[TKey], undefined>, Rest> extends never
? never
: K
: never
Expand Down

0 comments on commit f5aa11b

Please sign in to comment.