microsoft / microsoft/TypeScript
VSCode auto-import ignores typescript.preferences.importModuleSpecifierEnding when using a path from the package.json imports
Chưa có ai nhận issue này.
- 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
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- 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