-
-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-markdown@9.0.3
causes a significant increase in memory usage
#883
Comments
Sounds like an issue with TypeScript? Why not report it there? |
The performance regression appears to be due to how the type relationships are being constructed, rather than a TypeScript issue itself. In the original implementation:
The complex type relationship between BuildVisitor and Root is resolved once at the typedef level. In the new implementation:
TypeScript needs to resolve and compare these types each time the function used/referenced. This means that everytime, it needs to:
This leads to the deep type comparison traces we're seeing:
|
Because of the aa5933b, the emitted type definitions no longer contain
|
I don’t think that this happens; you are looking at JS but your TS is not reading JS. Like remco shows, you do not get the |
Closing, there is no reproduction, it is very vague what this is, whether something needs to or can be changed here. |
This comment has been minimized.
This comment has been minimized.
The way we used `ElementType` caused a significant increase of resource usage for TypeScript. I can’t really explain it, but this fixes it. I’m personally inclined to say people should avoid using the `JSX` namespace, but I see no other way around it. Without this change, autocompletion in my editor takes a noticable time to load. Now it’s instant. On my machine this halves the time of running `tsc -b` from ~15s to ~7s. Closes #883
Initial checklist
Affected package
react-markdown@9.0.3
Steps to reproduce
react-markdown
in a project@typescript/analyze-trace
Actual behavior
After upgrading
react-markdown
, TypeScript compilation shows significantly increased memory usage and type checking time. The TypeScript trace shows extremely long type comparison times (3300+ ms) when processing files that import react-markdown.This appears to be related to the recent change from
@typedef
to@import
in the type definitions.Previously
@typedef {import('hast').Element} Element
was handled as a simpler JSDoc annotation.@import {Element} from 'hast'
forces TypeScript to:The change from JSDoc annotations (
@typedef
) to TypeScript imports (@import
) represents an implementation change that affects build performance for consumers.Such changes should ideally be released as a minor version bump rather than a patch version, since patch versions should only contain backwards compatible bug fixes.
Expected behavior
TypeScript should compile with similar resource usage and performance as previous versions.
Runtime
node@22.13.1
Package manager
pnpm@9.15.4
Operating system
macOS Sequoia 15.1.2
Build and bundle tools
No response
The text was updated successfully, but these errors were encountered: