Skip to content

fix(ESM): convert type declarations to ESM exports#3412

Open
benasher44 wants to merge 1 commit intodiegomura:masterfrom
benasher44:fix/esm-type-declarations
Open

fix(ESM): convert type declarations to ESM exports#3412
benasher44 wants to merge 1 commit intodiegomura:masterfrom
benasher44:fix/esm-type-declarations

Conversation

@benasher44
Copy link
Copy Markdown
Contributor

Summary

Replaces the legacy export = ReactPDF / declare namespace ReactPDF pattern in index.d.ts with proper ESM export declarations.

The CJS-style export assignment causes TS1203 for consumers using module: NodeNext or module: Node16:

Export assignment cannot be used when targeting ECMAScript modules.

Since v4 already dropped CJS from the runtime (feat!: drop cjs support in #2871), this aligns the type declarations with the actual module format.

Changes

  • Remove declare class ReactPDF and export = ReactPDF
  • Remove declare namespace ReactPDF wrapper
  • Add export to all interfaces and type aliases (previously non-exported namespace members)
  • All export class, export const, and export function declarations are unchanged (just un-indented)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

⚠️ No Changeset found

Latest commit: 32ccddb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@benasher44
Copy link
Copy Markdown
Contributor Author

Recommend viewing the diff with whitespace hidden

@benasher44 benasher44 force-pushed the fix/esm-type-declarations branch 2 times, most recently from cb1510a to 2b12ef3 Compare May 7, 2026 18:28
Replace the legacy `export = ReactPDF` / `declare namespace ReactPDF`
pattern with proper ESM export declarations. The CJS-style export
assignment causes TS1203 ("Export assignment cannot be used when
targeting ECMAScript modules") for consumers using `module: NodeNext`
or `module: Node16`.

Since v4 already dropped CJS from the runtime, this aligns the type
declarations with the actual module format.

Changes:
- Remove `declare class ReactPDF` and `export = ReactPDF`
- Remove `declare namespace ReactPDF` wrapper
- Add `export` to all interfaces and type aliases (previously
  non-exported namespace members)
- All `export class`, `export const`, and `export function`
  declarations are unchanged (just un-indented)
@benasher44 benasher44 force-pushed the fix/esm-type-declarations branch from 2b12ef3 to 32ccddb Compare May 7, 2026 21:18
@benasher44 benasher44 changed the title feat: convert type declarations to ESM exports fix(ESM): convert type declarations to ESM exports May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant