steelbrain / steelbrain/node-ssh

@types/ssh2 are required when using TS `strictMode`

Open
#380 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1k
Forks
94
PR merge metrics
No merged PRs in 30d

Description

When using Typescript's strictMode, the compilation fails with the following error:

node_modules/node-ssh/lib/typings/index.d.ts:2:110 - error TS7016: Could not find a declaration file for module 'ssh2'. './node_modules/ssh2/lib/client.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/ssh2` if it exists or add a new declaration (.d.ts) file containing `declare module 'ssh2';`

2 import SSH2, { ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions, PseudoTtyOptions, ShellOptions } from 'ssh2';
                                                                                                               ~~~~~~

node_modules/node-ssh/lib/typings/index.d.ts:3:41 - error TS7016: Could not find a declaration file for module 'ssh2-streams'. './node_modules/ssh2-streams/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/ssh2-streams` if it exists or add a new declaration (.d.ts) file containing `declare module 'ssh2-streams';`

3 import { Prompt, TransferOptions } from 'ssh2-streams';
                                          ~~~~~~~~~~~~~~


Found 2 errors.

The fix is quite easy, simply install @types/ssh2 (which also installs @types/ssh2-streams, see here:

npm i --save-dev @types/ssh2

I think that installing the types dependencies is not the responsibility of the end user. Shouldn't the @types/ssh2 be installed as part of node-ssh dependencies or peerDependencies?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by checking how node-ssh declares dependencies and inspect the imports in node_modules/node-ssh/lib/typings/index.d.ts. Reproduce the reported TypeScript strictMode compilation failure, then verify that a consumer no longer needs to install the ssh2 type packages separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.