diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts
index d79def836396d..7c84d533443f5 100644
--- a/src/services/inlayHints.ts
+++ b/src/services/inlayHints.ts
@@ -44,6 +44,7 @@ import {
isCallSignatureDeclaration,
isConditionalTypeNode,
isConstructorTypeNode,
+ isConstructSignatureDeclaration,
isEnumMember,
isExpressionWithTypeArguments,
isFunctionDeclaration,
@@ -825,6 +826,15 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
visitForDisplayParts(node.type);
}
break;
+ case SyntaxKind.ConstructSignature:
+ Debug.assertNode(node, isConstructSignatureDeclaration);
+ parts.push({ text: "new " });
+ visitParametersAndTypeParameters(node);
+ if (node.type) {
+ parts.push({ text: ": " });
+ visitForDisplayParts(node.type);
+ }
+ break;
case SyntaxKind.ArrayBindingPattern:
Debug.assertNode(node, isArrayBindingPattern);
parts.push({ text: "[" });
diff --git a/tests/baselines/reference/inlayHintsVariableTypes3.baseline b/tests/baselines/reference/inlayHintsVariableTypes3.baseline
new file mode 100644
index 0000000000000..9b43534d8c51c
--- /dev/null
+++ b/tests/baselines/reference/inlayHintsVariableTypes3.baseline
@@ -0,0 +1,69 @@
+// === Inlay Hints ===
+const div = getCtor("div");
+ ^
+{
+ "text": "",
+ "displayParts": [
+ {
+ "text": ": "
+ },
+ {
+ "text": "{"
+ },
+ {
+ "text": " "
+ },
+ {
+ "text": "new "
+ },
+ {
+ "text": "("
+ },
+ {
+ "text": ")"
+ },
+ {
+ "text": ": "
+ },
+ {
+ "text": "DivElement",
+ "span": {
+ "start": 10,
+ "length": 10
+ },
+ "file": "/tests/cases/fourslash/inlayHintsVariableTypes3.ts"
+ },
+ {
+ "text": "; "
+ },
+ {
+ "text": "prototype"
+ },
+ {
+ "text": ": "
+ },
+ {
+ "text": "DivElement",
+ "span": {
+ "start": 10,
+ "length": 10
+ },
+ "file": "/tests/cases/fourslash/inlayHintsVariableTypes3.ts"
+ },
+ {
+ "text": " "
+ },
+ {
+ "text": "}"
+ },
+ {
+ "text": " | "
+ },
+ {
+ "text": "undefined"
+ }
+ ],
+ "position": 260,
+ "kind": "Type",
+ "whitespaceBefore": true
+}
\ No newline at end of file
diff --git a/tests/cases/fourslash/inlayHintsVariableTypes3.ts b/tests/cases/fourslash/inlayHintsVariableTypes3.ts
new file mode 100644
index 0000000000000..87c15a601089b
--- /dev/null
+++ b/tests/cases/fourslash/inlayHintsVariableTypes3.ts
@@ -0,0 +1,20 @@
+///
+
+// @strict: true
+// @target: esnext
+
+//// interface DivElement {}
+//// declare var DivElementCtor: {
+//// prototype: DivElement;
+//// new(): DivElement;
+//// };
+//// interface ElementMap {
+//// div: typeof DivElementCtor;
+//// }
+//// declare function getCtor(tagName: K): ElementMap[K] | undefined;
+//// const div = getCtor("div");
+
+verify.baselineInlayHints(undefined, {
+ includeInlayVariableTypeHints: true,
+ interactiveInlayHints: true
+});