Skip to content
This repository was archived by the owner on Feb 22, 2026. It is now read-only.
This repository was archived by the owner on Feb 22, 2026. It is now read-only.

Support TypeScript type casts in JSX #603

@joshkel

Description

@joshkel

🚀 Feature Proposal

i18next-parser cannot currently handle TypeScript as casts within a JSX file. For example:

<Trans>
  Hello, <strong>{{name} as any}</strong>!
</Trans>

gets extracted as "Hello, <1>{{ name } as any}</1>!" instead of "Hello, <1>{{name}}</1>!".

Motivation

As discussed in i18next/react-i18next#1483, React 18's type definitions cause TypeScript to start throwing errors for code such as

<Trans>
  Hello, <strong>{{name}}</strong>!
</Trans>

since a { name } object is not a valid React child. react-i18next offers a new allowObjectInHTMLChildren option to adjust TypeScript's type definitions to allow this; however, it's a fairly drastic option and causes all React children everywhere to allow arbitrary objects (even if they're not part of <Trans>).

An alternative is to use an as any cast (or similar) at the call site:

<Trans>
  Hello, <strong>{{name} as any}</strong>!
</Trans>

However, i18next-parser doesn't currently parse this properly.

Example

See above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions