Skip to content

Commit

Permalink
Reduce nesting of ContextOfKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Schweiger committed May 14, 2024
1 parent 1abbcf8 commit 55078b6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions typescript/t.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,12 @@ type ContextOfKey<
ActualNS extends Namespace = NsByTOptions<Ns, TOpt>,
ActualKeys = Keys[$FirstNamespace<ActualNS>],
> = $IsResourcesDefined extends true
? Key extends string
? Key extends `${infer Nsp}${_NsSeparator}${infer RestKey}`
? Nsp extends Namespace
? ContextOfKey<Nsp, RestKey, TOpt>
: never
: ActualKeys extends `${Key}${_ContextSeparator}${infer Context}`
? Context
? Key extends `${infer Nsp}${_NsSeparator}${infer RestKey}`
? Nsp extends Namespace
? ContextOfKey<Nsp, RestKey, TOpt>
: never
: ActualKeys extends `${Key extends string ? Key : never}${_ContextSeparator}${infer Context}`
? Context
: never
: string;

Expand Down

0 comments on commit 55078b6

Please sign in to comment.