So I'm creating an Angular 2 - typescript application and I want to be able to explore PDFs using Mozilla's PDFJS library. I have installed the depenedencies like so:
npm install pdfjs-dist @types/pdfjs-dist --save
Then in my app.modules.ts I attempt to import it like so:
import { PDFJS } from "pdfjs-dist";
And I'm met with the following error when trying to run tsc
I get the following output:
src-ng/csm/app/app.module.ts(27,10): error TS2305: Module '"pdfjs-dist"' has no exported member 'PDFJS'.
I'm at a loss because it appears that the pdfjs-dist typing appears to be in order. Is there something else I should include?
You have to import it like this:
import * as PDFJS from "pdfjs-dist";
// or individual members
import { getDocument } from "pdfjs-dist";
This is due to the way TypeScript handles interop between the old module specs (CommonJS, UMD, AMD) and ES6 modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With