Add missing whitespace after type parameter's modifiers in interactive inlay hints (#62246)

This commit is contained in:
Mateusz Burzyński 2025-10-29 17:24:57 +01:00 committed by GitHub
parent 8ea03f88d0
commit 11ee01b22d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 89 additions and 0 deletions

View File

@ -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: " " });
}
if (node.dotDotDotToken) {
parts.push({ text: "..." });

View File

@ -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
}

View File

@ -0,0 +1,10 @@
///<reference path="fourslash.ts" />
//// function test1() {
//// return function <const T>(a: T) {};
//// }
verify.baselineInlayHints(undefined, {
interactiveInlayHints: true,
includeInlayFunctionLikeReturnTypeHints: true,
});