Skip to content

fix(types): inline Primitive enum values for isolatedModules compatibility + sync enums#3411

Open
benasher44 wants to merge 2 commits intodiegomura:masterfrom
benasher44:fix/types-isolated-modules
Open

fix(types): inline Primitive enum values for isolatedModules compatibility + sync enums#3411
benasher44 wants to merge 2 commits intodiegomura:masterfrom
benasher44:fix/types-isolated-modules

Conversation

@benasher44
Copy link
Copy Markdown
Contributor

@benasher44 benasher44 commented May 7, 2026

Problem

The Primitive enum in packages/types/primitive.d.ts initializes its values from @react-pdf/primitives runtime imports:

import * as P from '@react-pdf/primitives';

export enum Primitive {
  G = P.G,
  Svg = P.Svg,
  // ...
}

This breaks under TypeScript's isolatedModules mode (and verbatimModuleSyntax), because enum members cannot be initialized from imported values when each file must be independently transpilable.

Fixed by inlining the string literal values directly + added a test to ensure these stay in sync

The Primitive enum in primitive.d.ts initializes values from
@react-pdf/primitives runtime imports, which breaks under TypeScript's
isolatedModules mode. Inline the string literal values directly since
they are stable constants.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

⚠️ No Changeset found

Latest commit: b62ed0d

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

Add missing enum members (FieldSet, TextInput, Select, Checkbox, List,
ImageBackground, Marker) and a bidirectional test that checks every
enum value matches @react-pdf/primitives and vice versa.
@benasher44 benasher44 changed the title fix(types): inline Primitive enum values for isolatedModules compatibility fix(types): inline Primitive enum values for isolatedModules compatibility + sync enums 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