Skip to content

[email protected] causes a significant increase in memory usage #883

@noahwaldner

Description

@noahwaldner

Initial checklist

Affected package

[email protected]

Steps to reproduce

  1. Use react-markdown in a project
  2. Run a typecheck with the --generateTrace option
  3. 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

[email protected]

Package manager

[email protected]

Operating system

macOS Sequoia 15.1.2

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🤷 no/invalidThis cannot be acted upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions