From 7de332c11beab66eb4a3068db1e771ebf651982b Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Fri, 11 Dec 2020 08:39:41 +0100 Subject: [PATCH] Accept const components prop for Trans. --- src/index.d.ts | 2 +- src/ts4.1/index.d.ts | 2 +- test/typescript/Trans.test.tsx | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 90affcc87..56cb91d6d 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -33,7 +33,7 @@ export interface TransProps extends React.HTMLProps, Partial { children?: React.ReactNode; - components?: readonly React.ReactNode[] | { [tagName: string]: React.ReactNode }; + components?: readonly React.ReactNode[] | { readonly [tagName: string]: React.ReactNode }; count?: number; defaults?: string; i18n?: i18n; diff --git a/src/ts4.1/index.d.ts b/src/ts4.1/index.d.ts index a68710c2b..6e4cb01d5 100644 --- a/src/ts4.1/index.d.ts +++ b/src/ts4.1/index.d.ts @@ -118,7 +118,7 @@ export interface TransProps< E extends Element = HTMLDivElement > extends React.HTMLProps { children?: React.ReactNode; - components?: React.ReactNode[] | { [tagName: string]: React.ReactNode }; + components?: readonly React.ReactNode[] | { readonly [tagName: string]: React.ReactNode }; count?: number; defaults?: string; i18n?: i18n; diff --git a/test/typescript/Trans.test.tsx b/test/typescript/Trans.test.tsx index 633a8933e..da1ea1a22 100644 --- a/test/typescript/Trans.test.tsx +++ b/test/typescript/Trans.test.tsx @@ -26,6 +26,13 @@ function objectComponents() { return }} defaults="Hello " />; } +function constObjectComponents() { + const constObject = { + Btn: