Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Aug 9, 2025

No description provided.

@Copilot Copilot AI review requested due to automatic review settings August 9, 2025 22:55
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Aug 9, 2025
@typescript-bot typescript-bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 9, 2025
@typescript-bot
Copy link
Collaborator

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
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copy link

@Copilot Copilot AI left a 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

@@ -582,6 +582,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
Debug.assertNode(node, isTypeParameterDeclaration);
if (node.modifiers) {
visitDisplayPartList(node.modifiers, " ");
parts.push({ text: " " });
Copy link
Preview

Copilot AI Aug 9, 2025

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.

Copilot uses AI. Check for mistakes.

@@ -597,6 +598,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
Debug.assertNode(node, isParameter);
if (node.modifiers) {
visitDisplayPartList(node.modifiers, " ");
parts.push({ text: " " });
}
Copy link
Preview

Copilot AI Aug 9, 2025

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.

Suggested change
}
if (node.modifiers) {
visitDisplayPartList(node.modifiers, " ");
}

Copilot uses AI. Check for mistakes.

@@ -597,6 +598,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
Debug.assertNode(node, isParameter);
if (node.modifiers) {
visitDisplayPartList(node.modifiers, " ");
parts.push({ text: " " });
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

2 participants