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

オープン
#380 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
node.js, typescript
領域
backend

調査の方向性

まず、node-ssh が依存関係をどのように宣言しているかを確認し、node_modules/node-ssh/lib/typings/index.d.ts の imports を調べます。報告された TypeScript strictMode のコンパイル失敗を再現し、その後、consumer が ssh2 の型パッケージを別途インストールする必要がなくなったことを確認します。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
TypeScript
スター
1k
フォーク
94
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

steelbrain/node-ssh のほかの issue

steelbrain/node-ssh の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。