Skip to content

FE-594: Fix PDFDocumentProxy type mismatch in pdf-preview#8636

Merged
TimDiekmann merged 1 commit intomainfrom
t/fe-594-fix-tsc-error-on-main-in-pdf-preview
Apr 16, 2026
Merged

FE-594: Fix PDFDocumentProxy type mismatch in pdf-preview#8636
TimDiekmann merged 1 commit intomainfrom
t/fe-594-fix-tsc-error-on-main-in-pdf-preview

Conversation

@TimDiekmann
Copy link
Copy Markdown
Member

@TimDiekmann TimDiekmann commented Apr 16, 2026

🌟 What is the purpose of this PR?

Fix a tsc error in pdf-preview.tsx / pdf-search.tsx caused by PDFDocumentProxy type divergence between the hoisted pdfjs-dist and the version bundled inside react-pdf.

🔗 Related links

🚫 Blocked by

Nothing.

🔍 What does this change?

  • Replaces import type { PDFDocumentProxy } from "pdfjs-dist" with DocumentCallback from react-pdf/dist/cjs/shared/types in both pdf-preview.tsx and pdf-search.tsx.
  • DocumentCallback is react-pdf's own alias for PDFDocumentProxy, guaranteed to match its bundled pdfjs-dist version.
  • pdfjs-dist was never a declared dependency of @apps/hash-frontend — the import only resolved via yarn hoisting. import/no-extraneous-dependencies didn't catch it because the rule is only scoped to test/storybook/config files in the base eslint config.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • pdfjs-dist is still not a declared dependency — TextItem in pdf-search.tsx still imports from pdfjs-dist/types/src/display/api (react-pdf v9 doesn't re-export it). Adding it explicitly or bumping to react-pdf v10 (which does re-export TextItem) are follow-up options.
  • import/no-extraneous-dependencies is not active for regular source files in the base eslint config — only for tests, storybooks, and config files. This allowed the undeclared import to go unnoticed.

🐾 Next steps

  • Consider adding pdfjs-dist as an explicit dependency pinned to react-pdf's version.
  • Consider enabling import/no-extraneous-dependencies globally in the eslint base config.

🛡 What tests cover this?

  • tsc --noEmit (the build would have failed without this fix)

❓ How to test this?

  1. cd apps/hash-frontend && yarn lint:tsc
  2. Confirm no errors in pdf-preview.tsx or pdf-search.tsx.

`react-pdf` 9.2.1 bundles its own `pdfjs-dist` 4.8.69 whose
`PDFDocumentProxy` type has diverged from the hoisted copy that the
direct `import type { PDFDocumentProxy } from "pdfjs-dist"` resolves
to. Replace with react-pdf's `DocumentCallback` alias which points at
its own bundled version.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Apr 16, 2026 11:59am
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign Ignored Ignored Apr 16, 2026 11:59am
hashdotdesign-tokens Ignored Ignored Apr 16, 2026 11:59am
petrinaut Skipped Skipped Apr 16, 2026 11:59am

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 16, 2026

PR Summary

Low Risk
Type-only changes to align third-party library typings; no runtime logic changes beyond compile-time safety.

Overview
Fixes a TypeScript type mismatch introduced by the react-pdf upgrade by no longer importing PDFDocumentProxy from the hoisted pdfjs-dist.

pdf-preview.tsx and pdf-search.tsx now type the loaded PDF document as react-pdf’s DocumentCallback (including the PdfSearch prop and documentProxy state), aligning types with the pdfjs-dist version bundled inside react-pdf and unblocking tsc.

Reviewed by Cursor Bugbot for commit 83d9f4b. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added area/apps > hash* Affects HASH (a `hash-*` app) type/eng > frontend Owned by the @frontend team area/apps labels Apr 16, 2026
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 16, 2026

🤖 Augment PR Summary

Summary: Resolves a TypeScript type mismatch in the PDF preview/search components caused by divergent PDFDocumentProxy types between hoisted pdfjs-dist and the version used by react-pdf.
Change: Switches the document proxy types to DocumentCallback from react-pdf/dist/cjs/shared/types in pdf-preview.tsx and pdf-search.tsx to ensure they match react-pdf’s bundled PDF.js types.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copy link
Copy Markdown
Contributor

@alex-e-leon alex-e-leon left a comment

Choose a reason for hiding this comment

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

LGTM. Next steps sound great too.

@TimDiekmann TimDiekmann added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit d594b27 Apr 16, 2026
49 checks passed
@TimDiekmann TimDiekmann deleted the t/fe-594-fix-tsc-error-on-main-in-pdf-preview branch April 16, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants