Skip to content

Compiler crash with RangeError: Map maximum size exceeded #55630

Closed
@Grohden

Description

@Grohden

🔎 Search Terms

RangeError: Map maximum size exceeded
RangeError: Value undefined out of range for undefined options property undefined (node 16)
react types
antd types
fontawesome types

🕗 Version & Regression Information

  • This is a crash
  • I've tested this with the latest nightly (5.3.0-dev.20230904), 5.2.2 and 5.1.6
  • I was unable to test this on prior versions because I've converted my code to ts and it started to occur

⏯ Playground Link

No response

💻 Code

Simple file:

import React from 'react';
import {Menu} from 'antd';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';

type IconProp = React.ComponentProps<typeof FontAwesomeIcon>['icon'];

type Props =
  & React.PropsWithChildren<{ icon: IconProp }>
  & React.ComponentProps<typeof Menu.Item>

export const Item = ({icon}: Props) => {
  return <FontAwesomeIcon icon={icon}/>;
};

package.json

{
  "name": "ts-compiler-crash",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.4.2",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@types/react": "^18.2.21",
    "typescript": "^5.2.2",
    "antd": "~4.2.0"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es2019", "es6", "dom"],
    "module": "es6",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es6",
    "jsx": "react",
    "noEmit": true,
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noFallthroughCasesInSwitch": true
  }
}

🙁 Actual behavior

Compiler crashes with

yarn tsc
yarn run v1.22.19
$ /Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/.bin/tsc
/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:116479
      throw e;
      ^

RangeError: Map maximum size exceeded
    at Map.set (<anonymous>)
    at recursiveTypeRelatedTo (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60782:18)
    at isRelatedTo (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60199:122)
    at typeRelatedToSomeType (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60460:25)
    at unionOrIntersectionRelatedTo (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60380:16)
    at structuredTypeRelatedToWorker (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60959:23)
    at structuredTypeRelatedTo (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60801:21)
    at recursiveTypeRelatedTo (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60754:19)
    at isRelatedTo (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60199:122)
    at eachTypeRelatedToType (/Users/gabrielrohden/Desktop/Projects/Personal/ts-compiler-crash/node_modules/typescript/lib/tsc.js:60555:25)

Node.js v18.17.1
error Command failed with exit code 1.

🙂 Expected behavior

The compiler to at least not crash :/

Additional information about the issue

There's a related issue #50290

But its closed, so I'm opening a new one since that one wasn't really fixed but workarounded

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions