-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Typescript types definition missing for es5 build #12827
Comments
/cc @tamuratak @ineiti Could one of you perhaps comment here on how this works? I believe the existing types that you added/improved should be generally available if I'm not mistaken, but I'm not sure how to test this. |
I think it is an easy solution to tell users write the following: const pdfjsLib: typeof import('pdfjs-dist') = require('pdfjs-dist/es5/build/pdf.js'); See doc for If we want an out-of-the-box solution, it is not easy. The TypeScript compiler finds the type file "license": "Apache-2.0",
"main": "build/pdf.js",
"name": "pdfjs-dist",
"repository": {
"type": "git",
"url": "git+https://github.com/mozilla/pdfjs-dist.git"
},
"types": "types/pdf.d.ts",
"version": "2.6.347" Therefore, the TypeScript compiler cannot find the type file The only workaround we can have is putting a export * from 'pdfjs-dist' |
I think the first approach can not work when ES Modules are used cause require is not allowed there. My guess is that the second approach would be far better. Tanks for looking into this! |
Given that this particular issue seem to be mostly related to building/packaging the PDF.js library, rather than TypeScript as such, I've submitted a small patch following the suggestion in #12827 (comment). @tamuratak Thanks for your help! @lanwin Please keep in mind that the PDF.js library is still a JavaScript project; hence it's generally speaking going to be up to the TypeScript users themselves to help maintain/improve the definitions where necessary :-) |
The current type definition did only work if pdfjs is directly imported, but not if the es5 build is used (when used with node).
I had to add a d.ts file to make it work. But I think this should be directly included in the release.
The text was updated successfully, but these errors were encountered: