microsoft / microsoft/TypeScript

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

Open
#45,149 9 comments 12 reactions 1 assignee View on GitHub

@weswigham is already working on this.

Since Jul 22, 2021.

Needs Investigation Rescheduled
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.