TypeScript: Expression produces a union type that is too complex to represent. ts(2590)

See original GitHub issue

πŸ› Bug report

in some cases, instead of updating the theme, we want to change some defaults in components directly, to fit a more opinionated approach, and proxy ChakraUI components … f.ex:

import { ModalBody as ModalBodyComponent, ModalBodyProps } from '@chakra-ui/modal';
import { forwardRef } from '@chakra-ui/system';
import * as React from 'react';

export const ModalBody = forwardRef<ModalBodyProps, 'div'>((props, ref) => {
  return <ModalBodyComponent pb={6} {...props} ref={ref} />;
});

πŸ’₯ Steps to reproduce

components with a lot of props (number unknown) seem to be the culprit

πŸ’» Link to reproduction

Note, I cannot seem to reproduce this on Codesandbox, but I can reproduce this locally in a clean project, So i suggest cloing the codesandbox locally. CodeSandbox reproduction: https://codesandbox.io/s/summer-night-bmzsl?file=/src/ModalBody.tsx

🧐 Expected behavior

union types should not be extra complex using this method

🧭 Possible Solution

n/a

🌍 System information

Software Version(s)
Chakra UI β€œ@chakra-ui/modal”: β€œ1.7.0”, β€œ@chakra-ui/system”: β€œ1.4.0”, β€œ@chakra-ui/utils”: β€œ1.4.0”,
Browser n/a
Operating System MacOS

πŸ“ Additional information

could be related to #3706

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
Daggy1234commented, Apr 25, 2021

Hey so I’m habing the same problem with this Jsx snippet.

                                   <MenuButton
                                        size="lg"
                                        borderColor="transparent"
                                        variant="outline"
                                        as={Button}
                                        rightIcon={<FaChevronDown />}>
                                        <Avatar size="md" src={user.photoURL} alt={user.name} />
                                    </MenuButton>

Expression produces a union type that is too complex to represent.ts(2590)

I’m on: β€œ@chakra-ui/react”: β€œ^1.1.0”, β€œnext”: β€œ10.0.4”, β€œtypescript”: β€œ^4.1.2”

9reactions
FreePhoenix888commented, Dec 25, 2022

Solution

  1. Open a JavaScript or TypeScript file in VS Code.
  2. In the VS Code command palette, run the TypeScript: Select TypeScript version command.
  3. Make sure you have Use workspace version selected

UPD: I have created a question+answer on stackoverflow. I hope it helps someone πŸ˜ƒ

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expression produces a union type that is too complex ... - GitHub
src/template-language-service-decorator.ts:44:13 - error TS2590: Expression produces a union type that is too complex to represent.
Read more >
TS Expression produces a union type that is too complex to ...
Solution 1. The stable version of MaterialUI fix this problem. Use this package: npm install @mui/material. Solution 2 by Vivere.
Read more >
ts2590: expression produces a union type that is too complex ...
1 Typescript Box produces a union type that is too complex to represent. Rendering a Box produces the following error: Expression produces a...
Read more >
typescript expression produces a union type that is too ...
I very confusing with error "typescript expression produces a union type that is too complex to represent" in NextJS, React.
Read more >
Matt Pocock on Twitter: "Reply with your TypeScript error ...
Reply with your TypeScript error message, and I'll translate it to plain ... Expression produces a union type that is too complex to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found