From 0fb11403623c615f1236ada08e27dfd4edc3f71e Mon Sep 17 00:00:00 2001 From: Pedro Durek Date: Wed, 9 Dec 2020 15:27:39 -0600 Subject: [PATCH] Fix issue which was defaulting TFunctionResult for t function (#1217) --- src/ts4.1/index.d.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/ts4.1/index.d.ts b/src/ts4.1/index.d.ts index 9d50c81d4..a68710c2b 100644 --- a/src/ts4.1/index.d.ts +++ b/src/ts4.1/index.d.ts @@ -84,30 +84,32 @@ export type TFuncKey = N extends (keyof T)[] ? Normalize : string; -export type TFuncReturn = N extends (keyof T)[] - ? NormalizeMultiReturn +export type TFuncReturn = [keyof Resources] extends [never] + ? TDefaultResult + : N extends (keyof T)[] + ? NormalizeMultiReturn : N extends keyof T - ? NormalizeReturn - : TFunctionResult; + ? NormalizeReturn + : string; export interface TFunction { < - K extends TFuncKey | TemplateStringsArray, - R extends TFuncReturn, - I extends object = StringMap + TKeys extends TFuncKey | TemplateStringsArray, + TDefaultResult extends TFunctionResult = string, + TInterpolationMap extends object = StringMap >( - key: K | K[], - options?: TOptions | string, - ): R; + key: TKeys | TKeys[], + options?: TOptions | string, + ): TFuncReturn; < - K extends TFuncKey | TemplateStringsArray, - R extends TFuncReturn, - I extends object = StringMap + TKeys extends TFuncKey | TemplateStringsArray, + TDefaultResult extends TFunctionResult = string, + TInterpolationMap extends object = StringMap >( - key: K | K[], + key: TKeys | TKeys[], defaultValue?: string, - options?: TOptions | string, - ): R; + options?: TOptions | string, + ): TFuncReturn; } export interface TransProps<