-
-
Notifications
You must be signed in to change notification settings - Fork 922
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Affected package
Steps to reproduce
- Use
react-markdownin a project - Run a typecheck with the --generateTrace option
- Analyze the trace with
@typescript/analyze-trace
Check file .../markdown.tsx (3388ms)
└─ Check deferred node from (line X, char X) to (line X, char X) (3341ms)
└─ Compare types 1971 and 1260 (3331ms)
└─ Compare types 1971 and 1247 (3327ms)
└─ Compare types 338 and 1946 (3327ms)
└─ Compare types 336 and 1261 (3327ms)
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:
- Load and process full type definitions from each imported package
- Maintain more complex type relationships in memory
- Perform deeper type analysis during comparisons
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
Package manager
Operating system
macOS Sequoia 15.1.2
Build and bundle tools
No response