DeviceFarmer / adbkit

A pure Node.js client for the Android Debug Bridge.
Other
219 stars 50 forks source link

npm library missing Typescript dependencies #120

Open jhilliker opened 3 years ago

jhilliker commented 3 years ago

ISSUE:

Installing adbkit does not install it's dependencies' type definitions.

> tsc

node_modules/@devicefarmer/adbkit/dist/src/ExtendedPublicKey.d.ts:1:21 - error TS7016: Could not find a declaration file for module 'node-forge'. '/home/j/dev/poke/node_modules/node-forge/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/node-forge` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-forge';`

1 import { pki } from 'node-forge';
                      ~~~~~~~~~~~~

node_modules/@devicefarmer/adbkit/dist/src/SocketOptions.d.ts:2:22 - error TS7016: Could not find a declaration file for module 'bluebird'. '/home/j/dev/poke/node_modules/bluebird/js/release/bluebird.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/bluebird` if it exists or add a new declaration (.d.ts) file containing `declare module 'bluebird';`

2 import Bluebird from 'bluebird';
...

A fresh project using adbkit is missing the dependencies from its package-lock.json:

...
    "node_modules/@devicefarmer/adbkit": {
      "version": "3.2.0",
      "resolved": "https://registry.npmjs.org/@devicefarmer/adbkit/-/adbkit-3.2.0.tgz",
      "integrity": "sha512-wfpaoASfRKBBAdyECHViVC534AVethZOMTkECLc6yf+qK46AROpAU3WWT15FuqeYjdQNnAY0SXVy0Y+gysTEZg==",
      "dependencies": {
        "@devicefarmer/adbkit-logcat": "^2.1.1",
        "@devicefarmer/adbkit-monkey": "~1.1.0",
        "bluebird": "~3.7",
        "commander": "^6.2.1",
        "debug": "~4.3.1",
        "node-forge": "^0.10.0",
        "split": "~1.0.1"
      },
...

I believe that the @type definitions should be included in the above.

Other project have them:

...
    "node_modules/@jest/console": {
      "version": "27.0.2",
      "resolved": "https://registry.npmjs.org/@jest/console/-/console-27.0.2.tgz",
      "integrity": "sha512-/zYigssuHLImGeMAACkjI4VLAiiJznHgAl3xnFT19iWyct2LhrH3KXOjHRmxBGTkiPLZKKAJAgaPpiU9EZ9K+w==",
      "dependencies": {
        "@jest/types": "^27.0.2",
        "@types/node": "*",
        "chalk": "^4.0.0",
        "jest-message-util": "^27.0.2",
        "jest-util": "^27.0.2",
        "slash": "^3.0.0"
      },
...

PROPOSED FIX:

Is the solution to make them production dependencies instead of dev dependencies?

WORKAROUND:

include the @type dependencies in the project using adbkit... even though it may not use the other libraries...

STEPS TO REPRODUCE:

  1. Create a new typescript project.
  2. npm install @devicefarmer/adbkit
  3. import Adb from '@devicefarmer/adbkit';
  4. npm run build (or tsc)
UrielCh commented 2 years ago

fixed in @u4/adbkit