Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add commonjs type definition file generation #365

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

grainrigi
Copy link
Contributor

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

Copy link
Owner

@modesty modesty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@modesty modesty merged commit f2d0115 into modesty:master Sep 27, 2024
1 check passed
@grainrigi grainrigi deleted the feat/cjsTyping branch September 27, 2024 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants