File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -121,8 +121,12 @@ namespace ts.InlayHints {
121121 }
122122
123123 function visitVariableLikeDeclaration ( decl : VariableDeclaration | PropertyDeclaration ) {
124+ if ( ! decl . initializer || isBindingPattern ( decl . name ) ) {
125+ return ;
126+ }
127+
124128 const effectiveTypeAnnotation = getEffectiveTypeAnnotationNode ( decl ) ;
125- if ( effectiveTypeAnnotation || ! decl . initializer ) {
129+ if ( effectiveTypeAnnotation ) {
126130 return ;
127131 }
128132
Original file line number Diff line number Diff line change 1+ /// <reference path="fourslash.ts" />
2+
3+ //// const object/*a*/ = { foo: 1, bar: 2 }
4+ //// const array/*b*/ = [1, 2]
5+ //// const a/*c*/ = object;
6+ //// const { foo, bar } = object;
7+ //// const {} = object;
8+ //// const b/*d*/ = array;
9+ //// const [ first, second ] = array;
10+ //// const [] = array;
11+
12+ const markers = test . markers ( ) ;
13+ verify . getInlayHints ( [
14+ {
15+ text : ': { foo: number; bar: number; }' ,
16+ position : markers [ 0 ] . position ,
17+ kind : ts . InlayHintKind . Type ,
18+ whitespaceBefore : true
19+ } ,
20+ {
21+ text : ': number[]' ,
22+ position : markers [ 1 ] . position ,
23+ kind : ts . InlayHintKind . Type ,
24+ whitespaceBefore : true
25+ } ,
26+ {
27+ text : ': { foo: number; bar: number; }' ,
28+ position : markers [ 2 ] . position ,
29+ kind : ts . InlayHintKind . Type ,
30+ whitespaceBefore : true
31+ } ,
32+ {
33+ text : ': number[]' ,
34+ position : markers [ 3 ] . position ,
35+ kind : ts . InlayHintKind . Type ,
36+ whitespaceBefore : true
37+ }
38+ ] , undefined , {
39+ includeInlayVariableTypeHints : true
40+ } ) ;
You can’t perform that action at this time.
0 commit comments