File tree Expand file tree Collapse file tree 3 files changed +99
-0
lines changed
Expand file tree Collapse file tree 3 files changed +99
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import {
4444 isCallSignatureDeclaration ,
4545 isConditionalTypeNode ,
4646 isConstructorTypeNode ,
47+ isConstructSignatureDeclaration ,
4748 isEnumMember ,
4849 isExpressionWithTypeArguments ,
4950 isFunctionDeclaration ,
@@ -825,6 +826,15 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
825826 visitForDisplayParts ( node . type ) ;
826827 }
827828 break ;
829+ case SyntaxKind . ConstructSignature :
830+ Debug . assertNode ( node , isConstructSignatureDeclaration ) ;
831+ parts . push ( { text : "new " } ) ;
832+ visitParametersAndTypeParameters ( node ) ;
833+ if ( node . type ) {
834+ parts . push ( { text : ": " } ) ;
835+ visitForDisplayParts ( node . type ) ;
836+ }
837+ break ;
828838 case SyntaxKind . ArrayBindingPattern :
829839 Debug . assertNode ( node , isArrayBindingPattern ) ;
830840 parts . push ( { text : "[" } ) ;
Original file line number Diff line number Diff line change 1+ // === Inlay Hints ===
2+ const div = getCtor("div");
3+ ^
4+ {
5+ "text": "",
6+ "displayParts": [
7+ {
8+ "text": ": "
9+ },
10+ {
11+ "text": "{"
12+ },
13+ {
14+ "text": " "
15+ },
16+ {
17+ "text": "new "
18+ },
19+ {
20+ "text": "("
21+ },
22+ {
23+ "text": ")"
24+ },
25+ {
26+ "text": ": "
27+ },
28+ {
29+ "text": "DivElement",
30+ "span": {
31+ "start": 10,
32+ "length": 10
33+ },
34+ "file": "/tests/cases/fourslash/inlayHintsVariableTypes3.ts"
35+ },
36+ {
37+ "text": "; "
38+ },
39+ {
40+ "text": "prototype"
41+ },
42+ {
43+ "text": ": "
44+ },
45+ {
46+ "text": "DivElement",
47+ "span": {
48+ "start": 10,
49+ "length": 10
50+ },
51+ "file": "/tests/cases/fourslash/inlayHintsVariableTypes3.ts"
52+ },
53+ {
54+ "text": " "
55+ },
56+ {
57+ "text": "}"
58+ },
59+ {
60+ "text": " | "
61+ },
62+ {
63+ "text": "undefined"
64+ }
65+ ],
66+ "position": 260,
67+ "kind": "Type",
68+ "whitespaceBefore": true
69+ }
Original file line number Diff line number Diff line change 1+ /// <reference path="fourslash.ts" />
2+
3+ // @strict : true
4+ // @target : esnext
5+
6+ //// interface DivElement {}
7+ //// declare var DivElementCtor: {
8+ //// prototype: DivElement;
9+ //// new(): DivElement;
10+ //// };
11+ //// interface ElementMap {
12+ //// div: typeof DivElementCtor;
13+ //// }
14+ //// declare function getCtor<K extends keyof ElementMap>(tagName: K): ElementMap[K] | undefined;
15+ //// const div = getCtor("div");
16+
17+ verify . baselineInlayHints ( undefined , {
18+ includeInlayVariableTypeHints : true ,
19+ interactiveInlayHints : true
20+ } ) ;
You can’t perform that action at this time.
0 commit comments