If the following compiler options are set, importing pdf2json causes an error if pdfparser.d.cts is not present:
module: "NodeNext" and moduleResolution: "NodeNext"
noImplicitAny: true
The resulting error is as follows:
error TS7016: Could not find a declaration file for module 'example-package'. '/home/naoki/WorkDir/js/modtest/node_modules/pdf2json/dist/pdfparser.cjs' implicitly has an 'any' type.
Try `npm i --save-dev @types/pdf2json` if it exists or add a new declaration (.d.ts) file containing `declare module 'pdf2json';`
import PDFParser from 'pdf2json';
~~~~~~~~~~
Output typescript definition for pdfparser.cjs.
problem solved by this
If the following compiler options are set, importing pdf2json causes an error if
pdfparser.d.cts
is not present:module: "NodeNext"
andmoduleResolution: "NodeNext"
noImplicitAny: true
The resulting error is as follows: