Typescript 4.5 Beta infinite loop leading to JS heap out of memory
See original GitHub issueAn issue appeared with TypeScript 4.5.0-dev.20211001 that made tsc go into an infinite loop leading to an out-of-memory error.
tsconfig.json:
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"lib": ["es2020"]
},
"exclude": ["node_modules"],
"include": ["run.ts"]
}
package.json:
{
"type": "commonjs",
"scripts": {
"start": "tsc -p ."
},
"dependencies": {
"zod": "^3.9.8"
},
"devDependencies": {
"typescript": "^4.5.0-beta"
}
when using tsc
directly, the following import cause the issue:
import { z } from "zod";
when using ts-node instead of tsc, this is the minimum necessary code to cause the issue:
import { z } from "zod";
const schema: z.ZodSchema<string> = z.string();
Demo code in: https://github.com/mmvsk/bug-zod-typescript-4.5.0-oct-01
The same code works until TypeScript 4.5.0-dev.20210930, and the issue was probably introduced with the following TypeScript PR: https://github.com/microsoft/TypeScript/pull/41821
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Javascript heap out of memory - angular
I solved the error by adding NODE_OPTIONS='--max-old-space-size=4096' to the build script in package.json as shown in the following example.
Read more >Documentation - TypeScript 4.5
These declaration files represent the available APIs in the JavaScript language, and the standard browser DOM APIs. While there are some reasonable defaults ......
Read more >Bug listing with status RESOLVED with resolution OBSOLETE ...
o.lock to be removed" displayed by libtool in infinite loop (e.g. ... amd64 due to out of memory error" status:RESOLVED resolution:OBSOLETE severity:normal ...
Read more >Top 5 Performance Metrics for Node.js Applications
Monitor and visualize Node.js application performance with these top five ... the heap memory usage should be completely flushed out.
Read more >Release notes and release history for Mobiscroll
... initial value for the time picker resulted in an infinite loop in Angular. ... We fixed the typescript type of the segmented...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Happy to see that fix land. I struggled to solve that issue for most of Saturday and made minimal progress. The
DeepPartial
thing is a much easier fix, I’ll look into it when I have a chance.Well, there is progress.
TypeScript was fixed (in https://github.com/microsoft/TypeScript/pull/46326), so now we have a clear error message instead of a memory error.
I created a new issue #715.