mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 09:24:19 -06:00
Fixed crash on ComputedPropertyName when computing interactive inlay hints (#61857)
This commit is contained in:
parent
36f7fbaded
commit
8665f920c9
@ -42,6 +42,7 @@ import {
|
||||
isBindingPattern,
|
||||
isCallExpression,
|
||||
isCallSignatureDeclaration,
|
||||
isComputedPropertyName,
|
||||
isConditionalTypeNode,
|
||||
isConstructorTypeNode,
|
||||
isConstructSignatureDeclaration,
|
||||
@ -886,6 +887,12 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
Debug.assertNode(node, isThisTypeNode);
|
||||
parts.push({ text: "this" });
|
||||
break;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
Debug.assertNode(node, isComputedPropertyName);
|
||||
parts.push({ text: "[" });
|
||||
visitForDisplayParts(node.expression);
|
||||
parts.push({ text: "]" });
|
||||
break;
|
||||
default:
|
||||
Debug.failBadSyntaxKind(node);
|
||||
}
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
// === Inlay Hints ===
|
||||
test((state) => {});
|
||||
^
|
||||
{
|
||||
"text": "",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": ": "
|
||||
},
|
||||
{
|
||||
"text": "{"
|
||||
},
|
||||
{
|
||||
"text": " "
|
||||
},
|
||||
{
|
||||
"text": "["
|
||||
},
|
||||
{
|
||||
"text": "STATE_SIGNAL",
|
||||
"span": {
|
||||
"start": 14,
|
||||
"length": 12
|
||||
},
|
||||
"file": "/tests/cases/fourslash/inlayHintsFunctionParameterTypes5.ts"
|
||||
},
|
||||
{
|
||||
"text": "]"
|
||||
},
|
||||
{
|
||||
"text": ": "
|
||||
},
|
||||
{
|
||||
"text": "unknown"
|
||||
},
|
||||
{
|
||||
"text": " "
|
||||
},
|
||||
{
|
||||
"text": "}"
|
||||
}
|
||||
],
|
||||
"position": 143,
|
||||
"kind": "Type",
|
||||
"whitespaceBefore": true
|
||||
}
|
||||
16
tests/cases/fourslash/inlayHintsFunctionParameterTypes5.ts
Normal file
16
tests/cases/fourslash/inlayHintsFunctionParameterTypes5.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/61845
|
||||
|
||||
//// declare const STATE_SIGNAL: unique symbol;
|
||||
////
|
||||
//// declare function test(
|
||||
//// cb: (state: { [STATE_SIGNAL]: unknown }) => void,
|
||||
//// ): unknown;
|
||||
////
|
||||
//// test((state) => {});
|
||||
|
||||
verify.baselineInlayHints(undefined, {
|
||||
includeInlayFunctionParameterTypeHints: true,
|
||||
interactiveInlayHints: true,
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user