vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
676 stars 174 forks source link

Build fails because of missing type #234

Closed olli-quartal closed 3 months ago

olli-quartal commented 3 months ago

Describe the bug and the expected behaviour

With the latest version, when building a project with reference to @signpdf the build fails at least with PNPM / TSC combination. The error is ../../node_modules/.pnpm/@signpdf+placeholder-pdf-lib@3.2.3_pdf-lib@1.17.1/node_modules/@signpdf/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts:5:14 - error TS2304: Cannot find name 'PDFPage'.

Is it a bug in signing or in the helpers?

The bug is in this commit: https://github.com/vbuch/node-signpdf/commit/474152be0cf015b7dcc36befaee511e43637cea2
in file packages/placeholder-pdf-lib/src/pdflibAddPlaceholder.js: A line with pdfPage: PDFPage has been added, but there is no typing for this (like there is e.g. for PDFDocument @typedef {import('pdf-lib').PDFDocument} PDFDocument)

To fix, probably just add:
@typedef {import('pdf-lib').PDFPage} PDFPage

vbuch commented 3 months ago

@olli-quartal this is fixed in 3.2.4. tsd was also introduced to the repo so that we limit the cases we mess up the produced types in future.