Skip to content

Respect quote preference for object property completions - #64359

Open
雪代 / Yukishiro (yksr-melt) wants to merge 1 commit into
microsoft:mainfrom
yksr-melt:fix/tsgo-object-property-quote-preference
Open

雪代 / Yukishiro (yksr-melt) wants to merge 1 commit into
microsoft:mainfrom
yksr-melt:fix/tsgo-object-property-quote-preference

Conversation

@yksr-melt

@yksr-melt 雪代 / Yukishiro (yksr-melt) commented Sep 20, 2026

Copy link
Copy Markdown

Fixes #63603

Completions for object literal property names that are not identifiers (for example "t1.id", from a key type built out of template literal types) were always inserted with double quotes, ignoring the quote style preference.

The name of these completions was built with a JSON-style string conversion, which always produces double quotes; a TODO: microsoft/TypeScript#18169 marked the missing preference. It now goes through quote, the helper other string literal completions already use, so an explicit single or double preference is respected and auto follows the quote style of the file's first import. Destructuring patterns share this code and are covered too, and the preference is also passed on the item resolve request, so a resolved item is found under the same name it was offered with. With double, or with auto in a file that has no single-quoted import, the completions are unchanged.

Not changed: the object literal method snippet variant (typescript.suggest.objectLiteralMethodSnippets.enabled). Its inserted text still copies the property name as written in the declaration.

Testing

Added tsc/internal/fourslash/tests/completionsObjectPropertyName_quotePreference_test.go:

  • single with the repro from the issue (Partial<Record<TableColumn, TableColumn>>).
  • single with names containing ', ", a space and -, plus a completion item resolve (through Detail) to check that the item is found with the same preference.
  • double, to check that the existing output, including escaping, is unchanged.
  • auto with a single-quoted first import.

The three tests that use the single-quote style fail without the change. The double test passes with and without it.

Local verification:

  • npx hereby check:format: passed.
  • go test ./... in tsc (what npx hereby test runs): all packages passed.
  • golangci-lint with the repo's custom build and .golangci.yml on the tsc module (what npx hereby lint runs first): 0 issues. The tools module could not be linted on my machine because some of its dependencies are not available offline; this change does not touch it.

AI assistance

I used Claude Code to help investigate the issue, write the change and the tests, and draft this description. I chose this issue, have reviewed the change, and will follow up on review feedback.

Copilot AI balanced review requested due to automatic review settings September 20, 2026 06:44
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 20, 2026
@typescript-automation typescript-automation Bot added For Backlog Bug PRs that fix a backlog bug labels Sep 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation consistently applies existing quote logic and includes focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Updates object-property completions to honor configured or inferred quote preferences.

Changes:

  • Applies quote preferences during completion generation and resolution.
  • Adds fourslash coverage for single, double, auto, escaping, and resolution behavior.
File Description
tsc/​internal/​ls/​completions.go Uses preferred quoting for object-property completion names.
tsc/​internal/​fourslash/​tests/​completionsObjectPropertyName_quotePreference_test.go Tests quote-style completion behavior.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

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

2 participants