TypeScript type declarations for .pdf file

Viewed 6165

I am new to TypeScript and I am simply trying to create a type definition for a pdf file and cannot locate any resources on how to do so. I am getting this warning where I import the file "Cannot find module <file_name.pdf> or its corresponding type declarations."

I would like to avoid changing my tsconfig.json file.

Thanks.

2 Answers

Rather than modifying the NPM package you can simply modify the tsconfig.js to add a custom typing, which is considerably more future-proof than the accepted solution.

Create the typings file in your src directory named: types.d.ts (or whatever). Insert:

declare module "*.pdf";

add this to your tsconfig:

"compilerOptions": {
    "typeRoots": ["./src/types"]
 ....
 }
Related