Skip to content

Commit

Permalink
Fix typing performance regression (#2166)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmeziere committed Apr 8, 2024
1 parent 0949a2b commit 3735a89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions typescript/t.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ type ParseKeysByFallbackNs<Keys extends $Dictionary> = _FallbackNamespace extend
? Keys[UnionFallbackNs]
: Keys[_FallbackNamespace & string];

type FilterKeysByContext<Keys, TOpt extends TOptions> = TOpt['context'] extends string
? Keys extends `${infer Prefix}${_ContextSeparator}${TOpt['context']}${infer Suffix}`
type FilterKeysByContext<Keys, Context> = Context extends string
? Keys extends `${infer Prefix}${_ContextSeparator}${Context}${infer Suffix}`
? `${Prefix}${Suffix}`
: never
: Keys;
Expand All @@ -128,12 +128,13 @@ export type ParseKeys<
KPrefix = undefined,
Keys extends $Dictionary = KeysByTOptions<TOpt>,
ActualNS extends Namespace = NsByTOptions<Ns, TOpt>,
const Context extends TOpt['context'] = TOpt['context'],
> = $IsResourcesDefined extends true
? FilterKeysByContext<
| ParseKeysByKeyPrefix<Keys[$FirstNamespace<ActualNS>], KPrefix>
| ParseKeysByNamespaces<ActualNS, Keys>
| ParseKeysByFallbackNs<Keys>,
TOpt
Context
>
: string;

Expand Down

0 comments on commit 3735a89

Please sign in to comment.