Skip to content

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

Description

@Gabilabrebi

πŸ”Ž 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.

TS.quote.issue.mp4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions