diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts index d79def836396d..ac9f55a1c04db 100644 --- a/src/services/inlayHints.ts +++ b/src/services/inlayHints.ts @@ -42,6 +42,7 @@ import { isBindingPattern, isCallExpression, isCallSignatureDeclaration, + isComputedPropertyName, isConditionalTypeNode, isConstructorTypeNode, isEnumMember, @@ -876,6 +877,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); } diff --git a/tests/baselines/reference/inlayHintsFunctionParameterTypes5.baseline b/tests/baselines/reference/inlayHintsFunctionParameterTypes5.baseline new file mode 100644 index 0000000000000..4251a4e389ef7 --- /dev/null +++ b/tests/baselines/reference/inlayHintsFunctionParameterTypes5.baseline @@ -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 +} \ No newline at end of file diff --git a/tests/cases/fourslash/inlayHintsFunctionParameterTypes5.ts b/tests/cases/fourslash/inlayHintsFunctionParameterTypes5.ts new file mode 100644 index 0000000000000..a66cac368a05a --- /dev/null +++ b/tests/cases/fourslash/inlayHintsFunctionParameterTypes5.ts @@ -0,0 +1,16 @@ +/// + +// 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, +});