File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1735,6 +1735,10 @@ function findExpressionCompleteTarget(code) {
17351735 // what we can potentially complete on, so let's re-run the function's logic on that
17361736 if ( lastBodyStatement . type === 'VariableDeclaration' ) {
17371737 const lastDeclarationInit = lastBodyStatement . declarations . at ( - 1 ) . init ;
1738+ if ( ! lastDeclarationInit ) {
1739+ // If there is no initialization we can simply return
1740+ return null ;
1741+ }
17381742 const lastDeclarationInitCode = code . slice ( lastDeclarationInit . start , lastDeclarationInit . end ) ;
17391743 return findExpressionCompleteTarget ( lastDeclarationInitCode ) ;
17401744 }
Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ function prepareREPL() {
5050}
5151
5252describe ( 'REPL tab completion (core functionality)' , ( ) => {
53+ it ( 'does not break with variable declarations without an initialization' , ( ) => {
54+ const { replServer } = prepareREPL ( ) ;
55+ replServer . complete ( 'let a' , getNoResultsFunction ( ) ) ;
56+ replServer . close ( ) ;
57+ } ) ;
58+
5359 it ( 'does not break in an object literal' , ( ) => {
5460 const { replServer, input } = prepareREPL ( ) ;
5561
You can’t perform that action at this time.
0 commit comments