Latest Update:
After the initial writing of this response, there have been significant changes to the type definitions. The package names have been updated to align with the NPM package, and a proper export definition has been included. Now, all you need to do is simply
npm install --save-dev @types/pdf-dist
.
Original Response:
The issue mentioned stems from a case of poor package naming. The @types/pdf
package offers types for Mozilla's PDF.js (which can be acquired via NPM using the pdfjs-dist
package), as opposed to the now outdated pdf
.
npm uninstall --save pdf
npm install --save pdfjs-dist
Furthermore, it seems that the @types/pdf
definitions solely designate PDF.js as a global variable rather than an importable module, despite the fact that the library is unquestionably receptive to being imported. To resolve this issue, add the following code snippet to your project:
declare module "pdfjs-dist" {
export = { PDFJS };
}
Subsequently, import PDF.js in the following manner:
import { PDFJS } from "pdfjs-dist";