How can I get TypeScript to load the PDF.js NPM module and @types bindings in a way that generates working Node.JS code?
Maybe you can use require
function.
Add @types/node
packages, and write require('pdfjs-dist')
at the top of the your source code.
So, you can modify your code like below.
Now, this code will work.
import { PDFJSStatic } from 'pdfjs-dist';
const PDFJS: PDFJSStatic = require('pdfjs-dist');
PDFJS.getDocument('helloworld.pdf').then(console.log);
I think that @types/pdfjs-dist
has problems in its implementation.