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.

Answer from Azoson on Stack Overflow
🌐
npm
npmjs.com › package › @types › pdfjs-dist
@types/pdfjs-dist - npm
Stub TypeScript definitions entry for pdfjs-dist, which provides its own types definitions. Latest version: 2.10.378, last published: 4 years ago. Start using @types/pdfjs-dist in your project by running `npm i @types/pdfjs-dist`. There are ...
      » npm install @types/pdfjs-dist
    
Published   Oct 28, 2021
Version   2.10.378
🌐
GitHub
github.com › mozilla › pdf.js › issues › 10547
Import pdf.js with typescript · Issue #10547 · mozilla/pdf.js
November 26, 2018 - Import pdfjs-dist in a *.ts file: import { PDFJS } from 'pdfjs-dist'; Use getDocument from PDFJS : PDFJS.getDocument('my.pdf') execute the code and see the error: PDFJS is not defined · What is the expected behavior? PDFJS works on typescript · What went wrong?
Published   Feb 12, 2019
🌐
Nutrient
nutrient.io › blog › sdk › how to build a typescript pdf viewer with pdfjs
How to build a TypeScript PDF viewer with PDF.js
October 15, 2024 - Since pdfjs-dist provides its own type definitions, you don’t need to install extra TypeScript typings.
🌐
npm
npmjs.com › package › pdfjs-dist
pdfjs-dist - npm
Generic build of Mozilla's PDF.js library.. Latest version: 5.4.449, last published: 12 days ago. Start using pdfjs-dist in your project by running `npm i pdfjs-dist`. There are 2279 other projects in the npm registry using pdfjs-dist.
      » npm install pdfjs-dist
    
Published   Nov 29, 2025
Version   5.4.449
🌐
CodeSandbox
codesandbox.io › examples › package › @types › pdfjs-dist
@types/pdfjs-dist examples - CodeSandbox
AboutStub TypeScript definitions entry for pdfjs-dist, which provides its own types definitions142,538Weekly Downloads
🌐
UNPKG
unpkg.com › browse › @types › [email protected] › index.d.ts
types/pdfjs-dist/index.d.ts
**/ interface PDFObjects { get(objId: number, callback?: any): any; resolve(objId: number, data: any): any; isResolved(objId: number): boolean; hasData(objId: number): boolean; getData(objId: number): any; clear(): void; } interface PDFJSUtilStatic { /** * Normalize rectangle so that (x1,y1) < (x2,y2) * @param {number[]} rect - the rectangle with [x1,y1,x2,y2] * * For coordinate systems whose origin lies in the bottom-left, this * means normalization to (BL,TR) ordering.
🌐
Apryse
apryse.com › blog › how-to-build-pdf-viewer-typescript-pdf-js
How to Build a PDF Viewer with TypeScript & PDF.js | Apryse
September 3, 2019 - Then extract the zip file, and from within the build folder, copy the pdf.js and pdf.worker.js files into the pdfjs-typescript/ folder. We won't be making any changes to these files. Now, it's time to take advantage of DefinitelyTyped, a popular open-source repository of declaration files that provide type validation for various JavaScript libraries, including PDF.js! We'll obtain the declaration file by running the following command: ... Navigate into the node_modules/@types/pdfjs-dist directory and add the following line at the top of the index.d.ts file:
Find elsewhere
🌐
GitHub
github.com › mozilla › pdf.js › issues › 12584
Add a basic typescript example · Issue #12584 · mozilla/pdf.js
November 5, 2020 - import * as pdfjsLib from 'pdfjs-dist'; // Error: 'Could not find a declaration file for module pdfjs-dist' let pdfjsLib = require('pdfjs-dist'); // is typed as 'any' // this does not work at all - i think that's maybe a pretty old example import { PDFJSStatic } from 'pdfjs-dist'; const PDFJS: PDFJSStatic = require('pdfjs-dist');
Published   Nov 05, 2020
🌐
Webdevtutor
webdevtutor.net › blog › typescript-pdfjs-dist
Using pdfjs-dist in TypeScript for PDF Manipulation
One of the key features of pdfjs-dist is its ability to load and display PDF files dynamically. Here's a simple example demonstrating how to load a PDF file and display it on a web page: const url = 'path/to/your/pdf/file.pdf'; pdfjs.getDocument(url).promise.then(pdf => { pdf.getPage(1).then(page => { const scale = 1.5; const viewport = page.getViewport({ scale }); const canvas = document.createElement('canvas'); const context = canvas.getContext('2d'); canvas.height = viewport.height; canvas.width = viewport.width; const renderContext = { canvasContext: context, viewport: viewport }; page.render(renderContext); document.body.appendChild(canvas); }); });
🌐
UNPKG
app.unpkg.com › @types › [email protected] › files › index.d.ts
types/pdfjs-dist
**/ interface PDFObjects { get(objId: number, callback?: any): any; resolve(objId: number, data: any): any; isResolved(objId: number): boolean; hasData(objId: number): boolean; getData(objId: number): any; clear(): void; } interface PDFJSUtilStatic { /** * Normalize rectangle so that (x1,y1) < (x2,y2) * @param {number[]} rect - the rectangle with [x1,y1,x2,y2] * * For coordinate systems whose origin lies in the bottom-left, this * means normalization to (BL,TR) ordering.
🌐
Stack Overflow
stackoverflow.com › questions › tagged › pdfjs-dist
Newest 'pdfjs-dist' Questions - Stack Overflow
I'm using versions below: "pdfjs-dist": "^5.4.394", "vue-pdf-embed": "... ... I have a pdf with the content in the attached pic PDF text with image - I need to figure out a way to correlate the text content and the image content on the page. everything is rendered in the ... ... I have a React Typescript application.
🌐
Stack Overflow
stackoverflow.com › questions › 73619530 › does-pdfjs-dist-can-run-with-typescript
vue.js - Does pdfjs-dist can run with Typescript? - Stack Overflow
import * as pdfjs from 'pdfjs-dist/es5/build/pdf'; import pdfjsWorker from 'pdfjs-dist/es5/build/pdf.worker.entry'; pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker; const pdfjsLib = pdfjs;
🌐
CodeSandbox
codesandbox.io › s › pdfjs-dist-with-ts-forked-4jczx7
pdfjs-dist-with-ts (forked) - CodeSandbox
October 26, 2023 - pdfjs-dist-with-ts (forked) using parcel-bundler, pdfjs-dist
Published   Oct 24, 2023
🌐
React PDF Viewer
react-pdf-viewer.dev › docs › getting-started
Getting started - React PDF Viewer
The TypeScript definition files of `@react-pdf-viewer` packages use `export type` syntax which is only available from TypeScript 3.8. ... React PDF Viewer uses the APIs provided by the popular pdfjs library. Execute the following command from the root folder to install pdfjs: ... If the installed version of `pdfjs-dist` requires the canvas package which has issues with Apple M1.