1
1
// Internal Helpers
2
2
type $MergeBy < T , K > = Omit < T , keyof K > & K ;
3
3
type $Dictionary < T = any > = { [ key : string ] : T } ;
4
- type $Value < Obj , Key > = Key extends keyof Obj ? Obj [ Key ] : never ;
5
4
type $OmitArrayKeys < Arr > = Arr extends readonly any [ ] ? Omit < Arr , keyof any [ ] > : Arr ;
6
5
type $PreservedValue < Value , Fallback > = [ Value ] extends [ never ] ? Fallback : Value ;
7
6
type $FirstNamespace < Ns extends Namespace > = Ns extends readonly any [ ] ? Ns [ 0 ] : Ns ;
@@ -866,14 +865,10 @@ type ParseTReturnPlural<
866
865
KeyWithPlural = `${Key & string } ${_PluralSeparator } ${PluralSuffix } `,
867
866
KeyWithOrdinalPlural = `${Key &
868
867
string } ${_PluralSeparator } ordinal${_PluralSeparator } ${PluralSuffix } `,
869
- > = KeyWithOrdinalPlural extends keyof Res
870
- ? Res [ KeyWithOrdinalPlural ]
871
- : KeyWithPlural extends keyof Res
872
- ? Res [ KeyWithPlural ]
873
- : $Value < Res , Key > ;
868
+ > = Res [ ( KeyWithOrdinalPlural | KeyWithPlural | Key ) & keyof Res ] ;
874
869
875
870
type ParseTReturn < Key , Res > = Key extends `${infer K1 } ${_KeySeparator } ${infer RestKey } `
876
- ? ParseTReturn < RestKey , $Value < Res , K1 > >
871
+ ? ParseTReturn < RestKey , Res [ K1 & keyof Res ] >
877
872
: ParseTReturnPlural < Res , Key > ;
878
873
879
874
type TReturnOptionalNull = _ReturnNull extends true ? null : never ;
@@ -891,7 +886,7 @@ export type TFunctionReturn<
891
886
ActualNS extends Namespace = NsByTOptions < Ns , TOpt > ,
892
887
> = $IsResourcesDefined extends true
893
888
? Key extends `${infer Nsp } ${_NsSeparator } ${infer RestKey } `
894
- ? ParseTReturn < RestKey , $Value < Resources , Nsp > >
889
+ ? ParseTReturn < RestKey , Resources [ Nsp & keyof Resources ] >
895
890
: ParseTReturn < Key , Resources [ $FirstNamespace < ActualNS > ] >
896
891
: DefaultTReturn < TOpt > ;
897
892
@@ -915,7 +910,6 @@ export interface TFunction<Ns extends Namespace = _DefaultNamespace, KPrefix = u
915
910
> (
916
911
...args :
917
912
| [ key : Key | Key [ ] , options ?: TOpt & InterpolationMap < Ret > ]
918
- | [ key : Key | Key [ ] , defaultValue : string , options ?: TOpt & InterpolationMap < Ret > ]
919
913
| [ key : string | string [ ] , options : TOpt & InterpolationMap < Ret > & { defaultValue : string } ]
920
914
| [ key : string | string [ ] , defaultValue : string , options ?: TOpt & InterpolationMap < Ret > ]
921
915
) : TFunctionReturnOptionalDetails < Ret , TOpt > ;
0 commit comments