Module '"stream"' can only be default-imported using the 'esModuleInterop' flag

Đang mở
#444 0 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ó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, typescript
Lĩnh vực
networking

Hướng nghiên cứu

Khai báo được báo cáo là node-ssh/lib/typings/index.d.ts; trước tiên hãy kiểm tra import stream của nó trên TypeScript 4.8.3 mà không có esModuleInterop. Xác minh rằng package vượt qua kiểm tra kiểu và việc sử dụng runtime hiện có vẫn hoạt động mà không yêu cầu consumer bật esModuleInterop.

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

Mô tả

When compiling with typescript 4.8.3 (at this time latest version), I am getting this error:

node_modules/node-ssh/lib/typings/index.d.ts:2:8 - error TS1259: Module '"stream"' can only be default-imported using the 'esModuleInterop' flag

2 import stream from 'stream';
~~~~~~

node_modules/@types/node/stream.d.ts:333:5
333 export = internal;
~~~~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

When setting esModuleInterop to true, typescript renders other used libraries properties with getters only e.g.:

prompt.message = '';
^

TypeError: Cannot set property message of # which has only a getter
at Object. (/home/cj/auto-config/auto-config-init.js:161:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47

Workaround: Editing file node_modules/node-ssh/lib/typings/index.d.ts so the line at the begining:
import stream from 'stream';to be:
import * as stream from 'stream';
solves issue for me without esModuleInterop flag set.

Can you please add this change in the next version?

Thank you in advance CJ

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.