Repository navigation
fix(types): ship @types/node-forge so consumers' type checks pass - #581
Merged
Merged
Conversation
ExtendedPublicKey's declaration extends node-forge's pki.rsa.PublicKey, so every TypeScript consumer that checks library types (skipLibCheck false, the default) needs node-forge's types. They were only a dev dependency, and a fresh project failed with TS7016 "Could not find a declaration file for module 'node-forge'". @types/node-forge is now a regular dependency. The type stays forge's own, so code that passes ExtendedPublicKey to forge keeps compiling. Fixes #120 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Karol Wrótniak <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
dist/src/ExtendedPublicKey.d.tsdoesimport { pki } from 'node-forge'(ExtendedPublicKey extends pki.rsa.PublicKey).@types/node-forgewas only a dev dependency, so a TypeScript consumer that checks library types (skipLibCheck: false, the default) fails:Fix
@types/node-forgemoves fromdevDependenciestodependencies, with the same range, and the lockfile is updated.ExtendedPublicKeystays forge's own type rather than a hand-written copy, so code that passes it to node-forge (stf'sadbkeyutil, for example) keeps compiling.Notes:
@types/node-forgedepends on@types/node: "*". A consumer that doesn't already have@types/nodenow gets the latest one through it, which is why the lockfile dropsdev: truefor@types/nodeandundici-types. The declarations already reference Node'sevents,net,stream,fsandchild_process, so a TS consumer needs Node types anyway.@devicefarmer/adbkit-logcatand@devicefarmer/adbkit-monkey) ship their own types. Thebluebirderror in the issue went away with 4.0.Fixes #120
Verification
A fresh consumer project:
npm i <packed tarball> typescript@~6.0.3 @types/node@22, withstrict: true,skipLibCheck: falseandmodule/moduleResolution: nodenext. It importsAdb,ExtendedPublicKey,Parser,ClientandDeviceClientfrom the entry point, plus the three deep imports, and readsk.fingerprintandk.nfrom anExtendedPublicKey.@typesinstalled:nodeonly.tscfails with TS7016 fornode-forgeinExtendedPublicKey.d.ts, and TS2339 becausendoesn't exist onExtendedPublicKey(the forge base type is lost).@typesinstalled:node node-forge.tsc OK.npm test: 284 passing.npm run lintis clean.🤖 Generated with Claude Code