Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pdfjs to @types/react-pdf #417

Closed
alondahari opened this issue Jun 25, 2019 · 6 comments
Closed

Add pdfjs to @types/react-pdf #417

alondahari opened this issue Jun 25, 2019 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@alondahari
Copy link

Before you start - checklist

  • [*] I understand that React-PDF does not aim to be a fully-fledged PDF viewer and is only a tool to make one
  • [*] I have checked if this feature request is not already reported

Is your feature request related to a problem? Please describe.

When importing pdfjs from the package (to define the remote worker) typescript can't compile because the definition doesn't exist on DefinitelyTyped

Describe the solution you'd like

Add the definition to the package

@wojtekmaj wojtekmaj added the help wanted Extra attention is needed label Jun 26, 2019
@wojtekmaj
Copy link
Owner

Maybe @CodeDaraW who created the types could be of any help?

@wojtekmaj wojtekmaj added the enhancement New feature or request label Jun 26, 2019
@CodeDaraW
Copy link

CodeDaraW commented Jun 26, 2019

You can import pdfjs from pdfjs-dist directly, that's the same thing.
I didn't import the type definition of pdfjs-dist, you may create a Pull Request for it.

@nikuda
Copy link

nikuda commented Sep 4, 2019

I added basic support for this by exporting version and GlobalWorkerOptions from @types/pdfjs-dist, and then exporting pdfjs-dist as pdfjs from @types/react-pdf.

import { Document, Page, pdfjs } from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc =
  `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;

Example above now works in TypeScript.

@wojtekmaj @CodeDaraW

@nikuda
Copy link

nikuda commented Sep 10, 2019

This has been merged as is now available in @types/react-pdf@^4.0.3. Make sure to delete your yarn.lock file to get @types/pdfjs-dist@^2.1.1 type changes as well.

Thanks @CodeDaraW for review.

@CodeDaraW
Copy link

Maybe @wojtekmaj can close the issue now.

@wojtekmaj
Copy link
Owner

Wow! Thanks so much to everyone involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants