microsoft / microsoft/TypeScript

Allow importModuleSpecifier: "relative" to be overridden for explicitly configured "paths" in a jsconfig/tsconfig

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

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

Awaiting More Feedback 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ả

This is a follow-up issue of https://github.com/microsoft/TypeScript/issues/40139

As per the docs, once you've imported a variable somewhere, vscode knows where to find it (bypassing the issue above).

I want all my code to be imported with relative imports everywhere for consistency. so I set "javascript.preferences.importModuleSpecifier": "relative". However, I don't want relative paths to be used when importing from a module declared in tsconfig's paths, as I specifically put it there so it can be resolved as an absolute import for convenience.

Clearly these 2 settings are conflicting, but I wonder if the current compromise is the best one (i.e. settings.json wins over tsconfig)?

I would expect to be able to auto-import variables from my paths module absolutely, even though I want everything else to import relatively.

  • VSCode Version: Insiders
  • OS Version: macOS 10.15.6

Steps to Reproduce:

  1. Clone this repo: https://github.com/Floriferous/paths-resolution
  2. Go to branch absolute-import-paths
  3. Notice test2.js imports someVar properly
  4. Open test.js, try to auto-import someVar, notice intellisense only suggests a relative import

Does this issue occur when all extensions are disabled?: Yes

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 việc tái hiện quá trình phân giải đường dẫn, đặc biệt là test.js, test2.js và cấu hình paths của jsconfig/tsconfig được tham chiếu; tái hiện các đề xuất auto-import khi đã bật tùy chọn ưu tiên đường dẫn tương đối. Theo dõi cách xử lý auto-import đối với các đường dẫn được cấu hình tường minh. Hoàn tất khi các import dựa trên paths được đề xuất dưới dạng tuyệt đối, trong khi các import khác vẫn giữ dạng tương đối.

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

Đánh giá

Công nghệ
javascript, typescript, vscode
Lĩnh vực
developer-experience, tooling
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.