modesty / pdf2json

converts binary PDF to JSON and text, for server-side PDF processing and command-line use.
https://github.com/modesty/pdf2json
Other
1.99k stars 378 forks source link

feat: add commonjs type definition file generation #365

Closed grainrigi closed 5 days ago

grainrigi commented 2 weeks ago

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:

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';
                      ~~~~~~~~~~