microsoft / microsoft/TypeScript

Don't include full paths in module names in error messages

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

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

Experience Enhancement Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

TypeScript Version: 4.0.5 (also tested with typescript@next)

Search Terms: namespace has no exported member error

Description

Currently certain error messages shows full file paths. For example:

Namespace '"y:/projects/opf/portal/OPF.Portal.Web/Content/Scripts/DinSide/App/Store/index"' has no exported member 'All'. ts(2694)

Could not find a declaration file for module 'shortid'. 'y:/projects/opf/portal/OPF.Portal.Web/node_modules/shortid/index.js' implicitly has an 'any' type.
Try npm install @types/shortid if it exists or add a new declaration (.d.ts) file containing declare module 'shortid'; ts(7016)

Our project was started without strict: true (and few @typescript-eslint rules), so the code base includes several thousand errors. To be able to gradually fix them, we have started to use betterer, which includes committing a snapshot of all the current errors. Snapshot is then used to report report when we fix errors, and fail our build if we add new errors. But because of certain Typescript errors using full file paths, we're getting unnecessary diffs in this snapshot.

Would it be possible to use file paths relative to the project/tsconfig.json root in the error messages instead?

So, with tsconfig.json in y:/projects/opf/portal/OPF.Portal.Web/, the error message would instead be:

Namespace '"Content/Scripts/DinSide/App/Store/index"' has no exported member 'All'. ts(2694)

An alternative solution could be to change betterer instead, make it auto-replace file paths with relative paths, or something like that. But figured I could at least ask here, especially since it could maybe be an issue for other tools as well.

Related Issues: Couldn't find any

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

Tái hiện các mã chẩn đoán 2694 và 7016 bằng các ví dụ và một tsconfig.json root, sau đó truy vết nơi tên mô-đun và đường dẫn tệp khai báo được định dạng. Hoàn tất khi các thông báo này sử dụng đường dẫn tương đối so với root của dự án mà không làm hỏng các chẩn đoán hiện có hoặc văn bản khai báo npm được đề xuất.

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

Đánh giá

Công nghệ
typescript
Lĩnh vực
compilers
Loại issue
Tính năng
Độ 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.