-
Notifications
You must be signed in to change notification settings - Fork 13k
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -582,6 +582,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] { | |||||||||
Debug.assertNode(node, isTypeParameterDeclaration); | ||||||||||
if (node.modifiers) { | ||||||||||
visitDisplayPartList(node.modifiers, " "); | ||||||||||
parts.push({ text: " " }); | ||||||||||
} | ||||||||||
visitForDisplayParts(node.name); | ||||||||||
if (node.constraint) { | ||||||||||
|
@@ -597,6 +598,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] { | |||||||||
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 commentThe 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 |
||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code duplicates the exact same logic that already exists in the
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||
if (node.dotDotDotToken) { | ||||||||||
parts.push({ text: "..." }); | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// === Inlay Hints === | ||
function test1() { | ||
^ | ||
{ | ||
"text": "", | ||
"displayParts": [ | ||
{ | ||
"text": ": " | ||
}, | ||
{ | ||
"text": "<" | ||
}, | ||
{ | ||
"text": "const" | ||
}, | ||
{ | ||
"text": " " | ||
}, | ||
{ | ||
"text": "T", | ||
"span": { | ||
"start": 44, | ||
"length": 1 | ||
}, | ||
"file": "/tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts" | ||
}, | ||
{ | ||
"text": ">" | ||
}, | ||
{ | ||
"text": "(" | ||
}, | ||
{ | ||
"text": "a" | ||
}, | ||
{ | ||
"text": ": " | ||
}, | ||
{ | ||
"text": "T", | ||
"span": { | ||
"start": 44, | ||
"length": 1 | ||
}, | ||
"file": "/tests/cases/fourslash/inlayHintsTypeParameterModifiers1.ts" | ||
}, | ||
{ | ||
"text": ")" | ||
}, | ||
{ | ||
"text": " => " | ||
}, | ||
{ | ||
"text": "void" | ||
} | ||
], | ||
"position": 16, | ||
"kind": "Type", | ||
"whitespaceBefore": true | ||
} | ||
|
||
return function <const T>(a: T) {}; | ||
^ | ||
{ | ||
"text": "", | ||
"displayParts": [ | ||
{ | ||
"text": ": " | ||
}, | ||
{ | ||
"text": "void" | ||
} | ||
], | ||
"position": 52, | ||
"kind": "Type", | ||
"whitespaceBefore": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
///<reference path="fourslash.ts" /> | ||
|
||
//// function test1() { | ||
//// return function <const T>(a: T) {}; | ||
//// } | ||
|
||
verify.baselineInlayHints(undefined, { | ||
interactiveInlayHints: true, | ||
includeInlayFunctionLikeReturnTypeHints: true, | ||
}); |
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 forSyntaxKind.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.