microsoft / microsoft/TypeScript

Mechanism to specify input source location to find `package.json` instead of output source location when determining module format

Đang mở
#63,251 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

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

Needs Proposal Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

🔎 Search Terms

nodenext, ts2351, construct

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "A default import of a commonjs module with a default in a esm file doesn't seem to be the default export of that module when module is node16 or nodenext".
⏯ Playground Link

N/A

💻 Code
git clone https://github.com/monsanto/typescript-nodenext-bug
cd typescript-nodenext-bug
npm install
npm run tsc
🙁 Actual behavior
foo/index.ts:6:5 - error TS2351: This expression is not constructable.
  Type 'typeof import("<dir>/typescript-nodenext-bug/.cache/foolib/class")' has no construct signatures.

6 new CBad();
      ~~~~


Found 1 error.
🙂 Expected behavior

It succeeds.

Additional information about the issue
  • This issue requires a composite project, NodeNext, a package boundary, a default export, and a parent directory with a file package.{json, json5, yaml} without type: module.
    • Please note that import default inside foo's package boundary works.
    • One can delete the provided package.json after installing and run node_modules/typescript/bin/tsc --build tsconfig-base.json to test without package.json present.
    • One can see other package extensions trigger the bug by mv package.json package.yaml and pnpm run tsc.
  • This is not a CommonJS project. It doesn't matter that there is a parent package.json without it. Node doesn't even read package.yaml.
    • This is from a real-world monorepo where there is a root pnpm package.json5 for cross-package scripts.

Cross-ref for #62200

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.

Hướng nghiên cứu

Bắt đầu với bản tái hiện typescript-nodenext-bug được liên kết: chạy npm install và npm run tsc, sau đó kiểm tra tsconfig-base.json cùng các biến thể package.json, package.json5 và package.yaml được mô tả trong issue. So sánh kết quả định dạng module NodeNext khi metadata của package cha có mặt hoặc không có; được xem là hoàn tất khi bản tái hiện thành công mà không có TS2351.

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

Đánh giá

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

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.