@@ -626,7 +626,7 @@ namespace ts.server {
626
626
627
627
const definitions = project . getLanguageService ( ) . getTypeDefinitionAtPosition ( file , position ) ;
628
628
if ( ! definitions ) {
629
- return undefined ;
629
+ return emptyArray ;
630
630
}
631
631
632
632
return definitions . map ( def => {
@@ -716,7 +716,7 @@ namespace ts.server {
716
716
const documentHighlights = project . getLanguageService ( ) . getDocumentHighlights ( file , position , args . filesToSearch ) ;
717
717
718
718
if ( ! documentHighlights ) {
719
- return undefined ;
719
+ return emptyArray ;
720
720
}
721
721
722
722
if ( simplifiedResult ) {
@@ -903,7 +903,7 @@ namespace ts.server {
903
903
}
904
904
}
905
905
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 > {
907
907
const file = toNormalizedPath ( args . file ) ;
908
908
const projects = this . getProjects ( args ) ;
909
909
@@ -913,7 +913,7 @@ namespace ts.server {
913
913
if ( simplifiedResult ) {
914
914
const nameInfo = defaultProject . getLanguageService ( ) . getQuickInfoAtPosition ( file , position ) ;
915
915
if ( ! nameInfo ) {
916
- return emptyArray ;
916
+ return undefined ;
917
917
}
918
918
919
919
const displayString = displayPartsToString ( nameInfo . displayParts ) ;
@@ -1167,19 +1167,16 @@ namespace ts.server {
1167
1167
} ) ;
1168
1168
}
1169
1169
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 {
1171
1171
const prefix = args . prefix || "" ;
1172
1172
const { file, project } = this . getFileAndProject ( args ) ;
1173
1173
1174
1174
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ;
1175
1175
const position = this . getPosition ( args , scriptInfo ) ;
1176
1176
1177
1177
const completions = project . getLanguageService ( ) . getCompletionsAtPosition ( file , position ) ;
1178
- if ( ! completions ) {
1179
- return emptyArray ;
1180
- }
1181
1178
if ( simplifiedResult ) {
1182
- return mapDefined ( completions . entries , entry => {
1179
+ return mapDefined ( completions && completions . entries , entry => {
1183
1180
if ( completions . isMemberCompletion || ( entry . name . toLowerCase ( ) . indexOf ( prefix . toLowerCase ( ) ) === 0 ) ) {
1184
1181
const { name, kind, kindModifiers, sortText, replacementSpan } = entry ;
1185
1182
const convertedSpan = replacementSpan ? this . decorateSpan ( replacementSpan , scriptInfo ) : undefined ;
0 commit comments