-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Add missing whitespace after type parameter's modifiers in interactive inlay hints #62246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing whitespace after type parameter's modifiers in interactive inlay hints #62246
Conversation
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
1 similar comment
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a formatting issue in TypeScript's interactive inlay hints where type parameter modifiers were missing proper whitespace after them. The fix ensures that when type parameters have modifiers (like const T), there's a space between the modifier and the type parameter name in the displayed hint.
- Adds whitespace after type parameter modifiers in inlay hints
- Adds whitespace after parameter modifiers in inlay hints
- Includes test coverage for the new formatting behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/services/inlayHints.ts |
Adds space character after modifiers for both type parameters and function parameters |
tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts |
New test case to verify proper spacing with const T type parameter |
tests/baselines/reference/inlayHintsTypeParameterModifiers1.baseline |
Expected output baseline showing correct spacing in inlay hints |
| Debug.assertNode(node, isTypeParameterDeclaration); | ||
| if (node.modifiers) { | ||
| visitDisplayPartList(node.modifiers, " "); | ||
| parts.push({ text: " " }); |
Copilot
AI
Aug 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code duplicates the exact same logic that already exists in the visitForDisplayParts function for SyntaxKind.TypeParameter case (line 584-586 in context). The spacing logic should be handled consistently in one place rather than duplicated.
| if (node.modifiers) { | ||
| visitDisplayPartList(node.modifiers, " "); | ||
| parts.push({ text: " " }); | ||
| } |
Copilot
AI
Aug 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code duplicates the exact same logic that already exists in the visitForDisplayParts function for SyntaxKind.Parameter case (line 600-602 in context). The spacing logic should be handled consistently in one place rather than duplicated.
| } | |
| if (node.modifiers) { | |
| visitDisplayPartList(node.modifiers, " "); | |
| } |
| Debug.assertNode(node, isParameter); | ||
| if (node.modifiers) { | ||
| visitDisplayPartList(node.modifiers, " "); | ||
| parts.push({ text: " " }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added this for consistency but I don't know if there is a sane way to test this. Parameter modifiers are only allowed in constructors, right? I think there might not be a way to have them displayed in an inlay hint
No description provided.