@@ -626,7 +626,7 @@ namespace ts.server {
626626
627627 const definitions = project . getLanguageService ( ) . getTypeDefinitionAtPosition ( file , position ) ;
628628 if ( ! definitions ) {
629- return undefined ;
629+ return emptyArray ;
630630 }
631631
632632 return definitions . map ( def => {
@@ -716,7 +716,7 @@ namespace ts.server {
716716 const documentHighlights = project . getLanguageService ( ) . getDocumentHighlights ( file , position , args . filesToSearch ) ;
717717
718718 if ( ! documentHighlights ) {
719- return undefined ;
719+ return emptyArray ;
720720 }
721721
722722 if ( simplifiedResult ) {
@@ -903,7 +903,7 @@ namespace ts.server {
903903 }
904904 }
905905
906- private getReferences ( args : protocol . FileLocationRequestArgs , simplifiedResult : boolean ) : protocol . ReferencesResponseBody | ReadonlyArray < ReferencedSymbol > {
906+ private getReferences ( args : protocol . FileLocationRequestArgs , simplifiedResult : boolean ) : protocol . ReferencesResponseBody | undefined | ReadonlyArray < ReferencedSymbol > {
907907 const file = toNormalizedPath ( args . file ) ;
908908 const projects = this . getProjects ( args ) ;
909909
@@ -913,7 +913,7 @@ namespace ts.server {
913913 if ( simplifiedResult ) {
914914 const nameInfo = defaultProject . getLanguageService ( ) . getQuickInfoAtPosition ( file , position ) ;
915915 if ( ! nameInfo ) {
916- return emptyArray ;
916+ return undefined ;
917917 }
918918
919919 const displayString = displayPartsToString ( nameInfo . displayParts ) ;
@@ -1167,19 +1167,16 @@ namespace ts.server {
11671167 } ) ;
11681168 }
11691169
1170- private getCompletions ( args : protocol . CompletionsRequestArgs , simplifiedResult : boolean ) : ReadonlyArray < protocol . CompletionEntry > | CompletionInfo {
1170+ private getCompletions ( args : protocol . CompletionsRequestArgs , simplifiedResult : boolean ) : ReadonlyArray < protocol . CompletionEntry > | CompletionInfo | undefined {
11711171 const prefix = args . prefix || "" ;
11721172 const { file, project } = this . getFileAndProject ( args ) ;
11731173
11741174 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ;
11751175 const position = this . getPosition ( args , scriptInfo ) ;
11761176
11771177 const completions = project . getLanguageService ( ) . getCompletionsAtPosition ( file , position ) ;
1178- if ( ! completions ) {
1179- return emptyArray ;
1180- }
11811178 if ( simplifiedResult ) {
1182- return mapDefined ( completions . entries , entry => {
1179+ return mapDefined ( completions && completions . entries , entry => {
11831180 if ( completions . isMemberCompletion || ( entry . name . toLowerCase ( ) . indexOf ( prefix . toLowerCase ( ) ) === 0 ) ) {
11841181 const { name, kind, kindModifiers, sortText, replacementSpan } = entry ;
11851182 const convertedSpan = replacementSpan ? this . decorateSpan ( replacementSpan , scriptInfo ) : undefined ;
0 commit comments