microsoft / microsoft/TypeScript

Issue: TypeScript autocomplete for template literal types ignores user's Quote Style preference

オープン
#63,603 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Domain: LS: Completion Lists
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
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

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAKghgIwDYQHJwLbQLxQOTACMeUAPvsAEx4DcAUKJFAMID2SArhgHbpZS48ASwAmJcngBucThFoNw0eMghtOPAVAAGAEgDeylHwgBfAHT61XXplNb6jaAClWQ7pr10oUVtwBcUAAKcABOwEIyADwAShAAxqwhIpGGquzWADSwiChWPAB8+fQm9AncAM7AUMAQlQEubh5ePv5Qnt5QzSZ0JUA

💻 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

エディターの引用符設定をシングルクォートにした状態で、リンク先の TypeScript Playground にある template-literal Record の例を再現します。まず、オブジェクトキーに対する TypeScript language service のオートコンプリート経路を追跡し、次に、候補として提示されたキーを受け入れたときに、設定された引用符スタイルが JavaScript と TypeScript の両方の設定で維持されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
developer-experience
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。