microsoft / microsoft/TypeScript

VSCode auto-import ignores typescript.preferences.importModuleSpecifierEnding when using a path from the package.json imports

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

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

Needs More Info
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

Mô tả

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

  • VS Code Version: 1.95.1
  • OS Version: MacOS 14.7

I have these settings in VSCode:

{
   "javascript.preferences.importModuleSpecifierEnding": "minimal",
   "typescript.preferences.importModuleSpecifierEnding": "minimal"
}

I have these setting in my package.json:

"imports": {
    "#src": ["./src/index.ts", "./src/index/tsx"],
    "#src/*": [
      "./src/*",
      "./src/*.ts",
      "./src/*.tsx",
      "./src/*/index.ts",
      "./src/*/index.tsx"
    ]
  },

I have these settings in my tsconfig.json

"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",

However, when I auto-import something that starts with #src/, it automatically appends a .js to the import (or a .ts if I have allowImportingTsExtensions on. This is ignoring my settings to use the minimum module specifier ending I set in VSCode.

It looks like the addition of the .ts functionality was added in this bugfix: https://github.com/microsoft/TypeScript/issues/52167. I'm not sure why it wasn't set to respect the vscode settings.

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 hành vi auto-import bằng cách sử dụng các import trong package.json, các thiết lập tsconfig.json và các tùy chọn của VS Code đã được báo cáo. Bắt đầu bằng cách lần theo cách TypeScript xử lý module-specifier, sau đó xác minh rằng các import sử dụng những đường dẫn như #src/ tuân theo phần kết thúc tối thiểu đã cấu hình mà không làm hồi quy hành vi hiện có của .js hoặc .ts.

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, vscode
Lĩnh vực
developer-experience, tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 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
42/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.