Skip to content

Printing JS constructor function type causes out-of-memory error #29597

@bowenni

Description

@bowenni

TypeScript Version: 3.2.2 and 3.3.0-rc

Search Terms:
heap out of memory

Code
First of all, I don't expect there to be a valid use case of what I'm describing below. In fact a miss configuration in my build settings lead me to this. However I don't expect TSC to completely crash. Also I found that TS 3.1 had no problems with the code below so this might be a regression of TS 3.2.

Steps to reproduce the heap OOM

  • npm install chart.js
  • cd into node_modules/chart.js/dist. You should find Chart.min.js there.
  • create a tsconfig.json with the following content
{
  "compilerOptions": {
      "target": "es5",
      "module": "commonjs",
      "downlevelIteration": true,
      "skipDefaultLibCheck": true,
      "moduleResolution": "node",
      "preserveConstEnums": false,
      "experimentalDecorators": true,
      "emitDecoratorMetadata": true,
      "jsx": "react",
      "noErrorTruncation": true,
      "noEmitOnError": false,
      "declaration": false,
      "stripInternal": true,
      "inlineSourceMap": true,
      "inlineSources": true,
      "sourceMap": false,
      "jsxFactory": "react",
      "noImplicitAny": true,
      "noImplicitReturns": true,
      "noImplicitThis": true,
      "noFallthroughCasesInSwitch": true,
      "strictNullChecks": true,
      "strictPropertyInitialization": true,
      "strictFunctionTypes": true,
      "noStrictGenericChecks": true,
      "noResolve": true,
      "types": [],
      "importHelpers": false,
      "allowJs": true,
      "checkJs": false
  },
  "files": [
      "./Chart.min.js",
  ],
  "compileOnSave": false
}
  • run tsc -p tsconfig.json --outDir foo and see the JavaScript heap out of memory thrown.

Expected behavior:
Emits a file foo/Chart.min.js.
TS 3.1.6 finishes this in 1.7 seconds without any errors.

Actual behavior:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Playground Link:
N/A

Related Issues:
This looks similar to #29326 and #29511 but I don't understand it deep enough to tell if it's a duplicate.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions