Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS2590: Expression produces a union type that is too complex to represent. #880

Open
cherepanov opened this issue Jan 21, 2025 · 1 comment

Comments

@cherepanov
Copy link

With @types/react v19 typecheck is broken

@types/react@19.0.7
@types/react-dom@19.0.3
tsc@5.0.3

TS2590: Expression produces a union type that is too complex to represent.

Reproduction

import {NumericFormat} from 'react-number-format'

const Component = (...props: any) => <NumericFormat {...props} />
@jraoult
Copy link

jraoult commented Jan 21, 2025

@cherepanov I also found that. This is because of the way the default value for the type parameter (InputAttributes) is defined. We can work around this issue by explicitly passing it with:

 <NumericFormat<
            Omit<
              ComponentPropsWithoutRef<"input">,
              "defaultValue" | "value" | "children"
            >
          >
          {...props}
/>

cf. https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_usecase#definitely-not-reacthtmlprops-or-reacthtmlattributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants