next-i18next: Typing error with React 18
Describe the bug
NextJS build is failing with React 18 and usage of <Trans> component.
Occurs in next-i18next version
11.0.0
Steps to reproduce
info - Loaded env from /.env
Failed to compile.
./src/components/Component.tsx:179:56
Type error: Type '{ freeDays: number; }' is not assignable to type 'ReactNode'.
Object literal may only specify known properties, and 'freeDays' does not exist in type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal'.
177 | <Trans i18nKey="subscribe.freeDays">
178 | You get
> 179 | <span className="family-bold">{{ freeDays }}</span>
| ^
180 | starting today
181 | </Trans>
182 | </p>
info - Checking validity of types .%
Expected behaviour
No typing errors when using variables in Trans component
OS (please complete the following information)
- Device: MBP 2019 16
- Browser: Chrome 100.0.4896.127
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 18 (10 by maintainers)
@pedrodurek Unfortunately, still not working !
It overrides React own definition types, so I’ve got an error like :
I’ve searched and tried to fix this, changing d.ts file :
Declare file into tsconfig.json (both include and typeRoots properties), changing file name but it continues to override base types.
@pedrodurek can you help…? There is probably a bit of confusion.
yeah @adrai, that’s correct!
allowObjectInHTMLChildren
will allow all html elements to accept object as children.@azuken would such a TypeScript option like
allowObjectInHTMLChildren
work for you? Please comment here: https://github.com/i18next/react-i18next/issues/1483 And maybe check also this PR: https://github.com/i18next/react-i18next/pull/1492 @isaachinman if you have some inputs regarding that, let us know…Typings for the
Trans
component come fromreact-i18next
, not this package. Please open an issue there.