Inlay hints for ThisType nodes (#56564)

This commit is contained in:
Maria José Solano 2023-11-27 16:57:01 -08:00 committed by GitHub
parent 921259ee02
commit 2f2d2f2bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View File

@ -77,6 +77,7 @@ import {
isRestTypeNode,
isSpreadElement,
isStringLiteral,
isThisTypeNode,
isTupleTypeNode,
isTypeLiteralNode,
isTypeNode,
@ -792,6 +793,10 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
parts.push({ text: tokenToString(node.operator) });
visitForDisplayParts(node.operand);
break;
case SyntaxKind.ThisType:
Debug.assertNode(node, isThisTypeNode);
parts.push({ text: "this" });
break;
default:
Debug.failBadSyntaxKind(node);
}

View File

@ -33,6 +33,23 @@ function foo1 () {
"whitespaceBefore": true
}
bar() {
^
{
"text": "",
"displayParts": [
{
"text": ": "
},
{
"text": "this"
}
],
"position": 130,
"kind": "Type",
"whitespaceBefore": true
}
const a = () => 1
^
{
@ -45,7 +62,7 @@ const a = () => 1
"text": "number"
}
],
"position": 135,
"position": 173,
"kind": "Type",
"whitespaceBefore": true
}
@ -62,7 +79,7 @@ const b = function () { return 1 }
"text": "number"
}
],
"position": 162,
"position": 200,
"kind": "Type",
"whitespaceBefore": true
}
@ -79,7 +96,7 @@ const c = (b) => 1
"text": "number"
}
],
"position": 189,
"position": 227,
"kind": "Type",
"whitespaceBefore": true
}

View File

@ -12,6 +12,9 @@
//// foo() {
//// return 1
//// }
//// bar() {
//// return this
//// }
//// }
//// const a = () => 1