Skip to content

Fix missing TypeScript declarations in published package#850

Merged
quantizor merged 2 commits intoquantizor:mainfrom
stevenocchipinti:fix-typescript
Mar 20, 2026
Merged

Fix missing TypeScript declarations in published package#850
quantizor merged 2 commits intoquantizor:mainfrom
stevenocchipinti:fix-typescript

Conversation

@stevenocchipinti
Copy link
Copy Markdown
Contributor

When a codebase uses v9.7.11 (and likely other versions too) an error is produced when importing markdown-to-jsx in a TypeScript project:

error TS7016: Could not find a declaration file for module 'markdown-to-jsx'.

Refer to issue #849.

Root cause

(According to AI)

UNICODE_PUNCT_R and UNICODE_WHITESPACE_R in utils.ts were exported var declarations without explicit type annotations. The build tool (@bunup/dts) uses oxc-transform's isolatedDeclaration() to generate .d.ts files, which requires all exported bindings to have explicit types — without them it emits TS9010 errors.

In CI these errors are fatal (process.exit(1) is called before any .d.ts files are written), so the published package ships without declarations. Locally the errors are non-fatal warnings, which is why the build appears to succeed.

The fix

Add : RegExp type annotations to both variables — two characters of change each.

Verification

The CI=true variable needs to be set to see the problem locally:

git checkout main
bun run build           # succeeds locally (misleading)
CI=true bun run build   # fails, no .d.ts files written

Once the type annotations have been added, it passes.

git checkout fix-typescript
CI=true bun run build           # succeeds locally

AI disclosure

Just a heads up, I used AI to find and implement this solution but did my own testing to prove that it works.

The tests are all passing either way and I've tested using this package in my own repo that was otherwise failing via yalc.

…ration generation

UNICODE_PUNCT_R and UNICODE_WHITESPACE_R were exported vars without explicit
type annotations. @bunup/dts uses oxc-transform's isolatedDeclaration() to
generate .d.ts files, which requires all exported bindings to have explicit
types. Without them, TS9010 errors are emitted. In CI (isCI=true), these
errors are fatal and cause process.exit(1) before any .d.ts files are
written — which is why published packages v9.7.10 and v9.7.11 were missing
their type declarations entirely.

Closes quantizor#849
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 56f27dd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
markdown-to-jsx Patch

Not sure what this means? Click here to learn what changesets are.

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

@stevenocchipinti
Copy link
Copy Markdown
Contributor Author

Just added a changeset after seeing that message... let me know if that's not enough detail for the md file

Copy link
Copy Markdown
Owner

@quantizor quantizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@quantizor quantizor merged commit 1c430ae into quantizor:main Mar 20, 2026
4 checks passed
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.

2 participants