microsoft / microsoft/TypeScript

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

Offen
#63,603 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Domain: LS: Completion Lists
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das template-literal Record-Beispiel im verlinkten TypeScript Playground, wobei die Editor-Einstellung für Anführungszeichen auf einfache Anführungszeichen gesetzt ist. Beginne damit, den Autovervollständigungspfad des TypeScript language service für Objektschlüssel nachzuverfolgen, und überprüfe anschließend, dass das Akzeptieren eines vorgeschlagenen Schlüssels den konfigurierten Anführungszeichenstil sowohl für JavaScript- als auch für TypeScript-Einstellungen beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
developer-experience
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.