question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Error: error TS2590: Expression produces a union type that is too complex to represent

See original GitHub issue

Baseline: TS 4.3.2 Test: e0648173719f8f2a01d775e326d8590556bb16cd

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

Dependencies

    "@fluentui/react-northstar": "^0.56.0",
    "@types/react": "^16.9.11"

tsconfig.json

{
    "compilerOptions": {
        "strictNullChecks": true,
        "skipLibCheck": true,
        "jsx": "react",
    }
}

test.tsx

import { Alignment, ComponentSlotStylesPrepared, TeamsThemeStylesProps, ToolbarCustomItemProps, ToolbarItemProps } from "@fluentui/react-northstar";
import * as React from "react";

// No error if this is absent or at the end of the file
type Unused = ComponentSlotStylesPrepared<NonNullable<TeamsThemeStylesProps["ToolbarCustomItem"]>, any>;

type ItemProps = ToolbarItemProps | ToolbarCustomItemProps;

type ItemPropsWithTooltip = ItemProps & {
  key?: string;
  tooltip?: string;
  tooltipAlign?: Alignment;
};

declare const ToolbarItem: React.ElementType<ItemPropsWithTooltip>;
declare const props: ItemPropsWithTooltip;
const { tooltip, key, tooltipAlign, ...rest } = props;

const _ = <ToolbarItem {...rest} />; // TS2590

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
moses-20commented, Dec 11, 2022

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

The error message seems to be misleading.

I had a database table of 5000+ entries exported to a JSON file. When I change the file to .ts extension, I get this error, but it is not so when I change to .js extension.

I decided to leave it as JSON as read from file using Node fs.

1reaction
versa-devcommented, Dec 2, 2022

I get that error on a static array of 2000+ objects (list of SNOMED codes) when I add an optional property (additionalInformation) to one object in the array.

export interface AllergyInfo {
  name: string;
  url: string;
}

/**
 * Represents a code with a type, a default coding and multiple language displays.
 */
export interface AllergySystemCodeExtension extends SystemCodeExtension {
  type: AllergyIdentificationType;
  defaultCoding: Coding;
  languageDisplays: {
    en: string;
    de: string;
    fr: string;
    it: string;
    rm: string;
  };
  additionalInformation?: Array<AllergyInfo>;
}

Error from the big array: Bildschirmfoto 2022-08-25 um 19 31 11

Here in a small array I have no error:

const bla: AllergySystemCodeExtension[] = [
  {
    type: AllergyIdentificationType.SITUATION,
    defaultCoding: {
      system: 'http://snomed.info/sct',
      code: '716186003',
      display: 'No known allergy'
    },
    languageDisplays: {
      en: 'No known allergy',
      de: 'Keine bekannte Allergie',
      fr: "pas d'allergie connue",
      it: 'nessuna allergia nota',
      rm: '?'
    },
    additionalInformation: [{name: 'bla', url: 'bla'}]
  },
]

The dependencies:

"devDependencies": {
    "@rollup/plugin-commonjs": "22.0.1",
    "@rollup/plugin-node-resolve": "13.3.0",
    "@types/uuid": "8.3.4",
    "rollup": "2.76.0",
    "rollup-plugin-peer-deps-external": "2.2.4",
    "rollup-plugin-postcss": "^4.0.2",
    "rollup-plugin-typescript2": "0.32.1",
    "rollup-plugin-vue": "6.0.0",
    "sass": "^1.5.1",
    "typescript": "4.5.5"
  },
  "peerDependencies": {
    "@i4mi/fhir_r4": "^1.1.1",
    "fhirpath": "^2.14.5",
    "quasar": "^2.7.4",
    "vue": "^3.2.37"
  }

Anyone had this before? Help please.

I am getting the same error for my ts file to export json constant in express.js project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS Expression produces a union type that is too complex to ...
So I try to create a new project with Material-UI V5 and I install other dependency one by one. In the begin the...
Read more >
ts2590: expression produces a union type that is too complex ...
Rendering a Box produces the following error: Expression produces a union type that is too complex to represent.ts (2590) As I can see...
Read more >
Matt Pocock on Twitter: "Reply with your TypeScript error ...
Reply with your TypeScript error message, and I'll translate it to plain English. ... Expression produces a union type that is too complex...
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 >
Union types should not have too many elements
TypeScript static code analysis. Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your TYPESCRIPT code.
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