Skip to content

<Trans> typing does not support interpolation deeper than first-level childrenΒ #1847

Open
@foucdeg

Description

@foucdeg

πŸ› Bug Report

The following code raises a Typescript error:

<Trans>
  <p>Ticket type β€œ{{ticketType}}” not supported</p>
</Trans>

The error is:

Object literal may only specify known properties, and 'ticketType' does not exist in type 'ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal'.

The following code does not raise the error:

<Trans>
  Ticket type β€œ{{ticketType}}” not supported
</Trans>

To Reproduce

<Trans>
  <p>Ticket type β€œ{{ticketType}}” not supported</p>
</Trans>

with react-i18next = 15.5.2, i18next = 24.2.3, typescript = 5.8.3, @types/react = 18.2.48

Expected behavior

No error should be raised.

Your Environment

  • runtime version: node v20.18
  • i18next version: 24.2.3
  • react-i18next version: 15.5.2
  • typescript version: 5.8.3
  • @types/react version: 18.2.48
  • os: Mac

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions