Fix inlay hints for trailing required rest elements - #64363
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 15:03
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation correctly handles the reported mappings and includes representative regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes inlay parameter hints for tuple rest parameters with trailing required elements and for parameters following destructured parameters.
Changes:
- Maps trailing tuple elements from the final call arguments.
- Continues hint processing after unnamed parameters.
- Adds fourslash regression tests and baselines.
| File | Description |
|---|---|
tsc/internal/ls/inlay_hints.go |
Corrects argument-to-parameter hint mapping. |
tsc/internal/fourslash/tests/inlayHintsRestParameters_trailingRequired_test.go |
Tests trailing required tuple elements. |
tsc/internal/fourslash/tests/inlayHintsParameterNames_destructuredParameter_test.go |
Tests hints after destructured parameters. |
tsc/testdata/baselines/reference/fourslash/inlayHints/inlayHintsRestParameters_trailingRequired.baseline |
Records expected rest-parameter hints. |
tsc/testdata/baselines/reference/fourslash/inlayHints/inlayHintsParameterNames_destructuredParameter.baseline |
Records expected destructured-parameter 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 #59979
Inlay parameter name hints were wrong for a rest parameter whose tuple type has required elements after the rest element, such as
...rest: [first: number, ...middle: string[], last: string]. Arguments were matched with the tuple elements from the start, sotest(10, 'a', 'b', 'c')gotlast:on'b'instead of'c', andtest(10, 'c')got...middle:on'c'.When the number of arguments is known (there is no spread argument), the elements after the rest element are now matched from the end: the rest element gets its hint on its first argument only, and the elements after it get theirs on the last arguments. Calls with a spread argument, and tuples with no elements after the rest element, are handled as before.
Hints also stopped at the first argument whose parameter has no name, such as a destructured parameter, so
foo({ a: 1 }, 2)forfunction foo({ a }: { a: number }, b: number)got no hint at all. Such an argument is now skipped and the following arguments still get their hints, as in the TypeScript 6.0 language service.Testing
Added two fourslash baseline tests in
tsc/internal/fourslash/tests:inlayHintsRestParameters_trailingRequired_test.go: the case from the issue, an empty rest element, a rest element at the start, a preceding fixed parameter, and a tuple with no elements after the rest element.inlayHintsParameterNames_destructuredParameter_test.go: a destructured parameter followed by a named parameter.Both fail without the change. The existing inlay hint baselines are unchanged.
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.