Use absolute file paths in error messages

Đang mở
#36,221 20 bình luận 59 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

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

Hướng nghiên cứu

Tái hiện vấn đề bằng yarn workspaces run tsc và đường dẫn ví dụ packages/koas-core/src/index.ts. Bắt đầu bằng cách theo dõi cách tsc định dạng đường dẫn tệp trong các chẩn đoán của nó; được coi là hoàn tất khi các chẩn đoán có thể tạo ra đường dẫn tuyệt đối hoặc cung cấp một cách được hỗ trợ để yêu cầu chúng, đồng thời vẫn giữ nguyên hành vi hiện tại nếu chưa được cấu hình.

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

Mô tả

Domain: Error Messages In Discussion Suggestion

Search Terms

absolute

Suggestion

Output absolute paths in type errors for tsc, or at least a way to specify this.

Use Cases

When type checking in monorepositories, typically tsc is run for each workspace. tsc is then run relative to the workspace it is run from, whereas developers are mostly interested in either the absolute path, or the path relative to the project root.

I have configured my terminal emulator so I can CTRL-click a file and then the file is opened in VSCode, even on the correct line. This works for tsc output in simple TypeScript projects, because the file paths are relative to the project root. This also works for example for ESLint output, because it prints absolute paths. This does not work for tsc in mono repositories, because the output of yarn workspaces run tsc is relative to that workspace.

Examples

Clone and install a TypeScript mono repository.

git clone https://gitlab.com/remcohaszing/koas.git
cd koas
yarn

Let’s open the project using VSCode, since its builtin terminal is preconfigured to work with CTRL-click.

Run yarn workspaces run tsc in the VSCode terminal. This should work fine.

Now mess up any type. I changed an instance of koas.Middleware to koas.Middlewar in packages/koas-core/src/index.ts.

Run yarn workspaces run tsc in the VSCode terminal again. Now this outputs an error and a file path. The file path is not clickable, because it can’t be resolved.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

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.

Issue khác của microsoft/TypeScript

Tất cả issue của microsoft/TypeScript

Issue tương tự

Thêm issue về Go

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.