microsoft / microsoft/TypeScript
Issue: TypeScript autocomplete for template literal types ignores user's Quote Style preference
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
🔎 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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在编辑器引号偏好设置为单引号的情况下,复现链接的 TypeScript Playground 中的 template-literal Record 示例。首先跟踪 TypeScript language service 针对对象键的自动补全路径,然后验证接受建议的键后,对于 JavaScript 和 TypeScript 偏好设置,配置的引号样式都能得到保留。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- developer-experience
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100