microsoft / microsoft/TypeScript
Issue: TypeScript autocomplete for template literal types ignores user's Quote Style preference
Chưa có ai nhận issue này.
- 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ả
🔎 Search Terms
List of keywords : "double", "quote", "preference", "style", "autcomplete", "template", "literral"
🕗 Version & Regression Information
TS Version : 6.0.3 or 7.0-rc
⏯ Playground Link
💻 Code
type TableName = 't1' | 't2';
type ColumnName = 'id' | 'value';
type TableColumn = `${TableName}.${ColumnName}`;
type Join = {
on: Partial<Record<TableColumn, TableColumn>>;
};
const test: Join = {
on: {
// Trigger autocomplete inside the object
}
};
🙁 Actual behavior
The key is inserted using double quotes (e.g., "t1.id": ...), overriding the user's preference for single quotes.
🙂 Expected behavior
The key should be inserted using the quote style defined in the editor's preferences (e.g., single quotes if 'single' is selected).
Additional information about the issue
When using template literal types as keys in a Record or object mapping, the TypeScript language service's autocomplete functionality consistently forces double quotes (") when inserting the suggested keys, regardless of the user's configured javascript.preferences.quoteStyle or typescript.preferences.quoteStyle settings.
https://github.com/user-attachments/assets/e562b5ab-bbd7-48bd-96f8-a9181f03ba2e
This behavior is inconsistent with how standard string keys or property names are handled and complicates code consistency when working with complex template literal types in type-safe mappings.
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 ví dụ template-literal Record trong TypeScript Playground được liên kết, với tùy chọn dấu ngoặc kép của trình soạn thảo được đặt thành dấu nháy đơn. Bắt đầu bằng cách lần theo đường dẫn tự động hoàn thành của TypeScript language service cho các khóa đối tượng, sau đó xác minh rằng việc chấp nhận một khóa được đề xuất sẽ giữ nguyên kiểu dấu ngoặc kép đã cấu hình cho cả tùy chọn JavaScript và TypeScript.
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
- developer-experience
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 68/100