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

Đang mở
#380 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, typescript
Lĩnh vực
backend

Hướng nghiên cứu

Trước tiên, hãy kiểm tra cách node-ssh khai báo các dependency và xem xét các import trong node_modules/node-ssh/lib/typings/index.d.ts. Tái hiện lỗi biên dịch TypeScript strictMode đã được báo cáo, sau đó xác minh rằng consumer không còn cần cài đặt riêng các gói kiểu của ssh2.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
TypeScript
Star
1k
Fork
94
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của steelbrain/node-ssh

Tất cả issue của steelbrain/node-ssh

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.