Respect quote preference for object property completions - #64359
Open
雪代 / Yukishiro (yksr-melt) wants to merge 1 commit into
Open
雪代 / Yukishiro (yksr-melt) wants to merge 1 commit into
雪代 / Yukishiro (yksr-melt) wants to merge 1 commit into
Conversation
Copilot started reviewing on behalf of
雪代 / Yukishiro (yksr-melt)
September 20, 2026 06:45
View session
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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#18169marked the missing preference. It now goes throughquote, the helper other string literal completions already use, so an explicitsingleordoublepreference is respected andautofollows 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. Withdouble, or withautoin 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:singlewith the repro from the issue (Partial<Record<TableColumn, TableColumn>>).singlewith names containing',", a space and-, plus a completion item resolve (throughDetail) to check that the item is found with the same preference.double, to check that the existing output, including escaping, is unchanged.autowith a single-quoted first import.The three tests that use the single-quote style fail without the change. The
doubletest passes with and without it.Local verification:
npx hereby check:format: passed.go test ./...intsc(whatnpx hereby testruns): all packages passed..golangci.ymlon thetscmodule (whatnpx hereby lintruns first): 0 issues. Thetoolsmodule 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.