Before you start - checklist
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
Maybe @CodeDaraW who created the types could be of any help?
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.
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
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.
Maybe @wojtekmaj can close the issue now.
Wow! Thanks so much to everyone involved.
Most helpful comment
This has been merged as is now available in
@types/react-pdf@^4.0.3. Make sure to delete youryarn.lockfile to get@types/pdfjs-dist@^2.1.1type changes as well.Thanks @CodeDaraW for review.