@@ -354,7 +354,7 @@ export class Session {
354
354
return params ;
355
355
}
356
356
357
- private enableLanguageServiceForProject ( project : ts . server . Project ) {
357
+ private enableLanguageServiceForProject ( project : ts . server . Project ) : void {
358
358
const { projectName} = project ;
359
359
if ( project . isClosed ( ) ) {
360
360
this . info ( `Cannot enable language service for closed project ${ projectName } .` ) ;
@@ -381,7 +381,7 @@ export class Session {
381
381
this . runGlobalAnalysisForNewlyLoadedProject ( project ) ;
382
382
}
383
383
384
- private disableLanguageServiceForProject ( project : ts . server . Project , reason : string ) {
384
+ private disableLanguageServiceForProject ( project : ts . server . Project , reason : string ) : void {
385
385
if ( ! project . languageServiceEnabled ) {
386
386
return ;
387
387
}
@@ -394,7 +394,7 @@ export class Session {
394
394
* Invoke the compiler for the first time so that external templates get
395
395
* matched to the project they belong to.
396
396
*/
397
- private runGlobalAnalysisForNewlyLoadedProject ( project : ts . server . Project ) {
397
+ private runGlobalAnalysisForNewlyLoadedProject ( project : ts . server . Project ) : void {
398
398
if ( ! project . hasRoots ( ) ) {
399
399
return ;
400
400
}
@@ -410,7 +410,7 @@ export class Session {
410
410
}
411
411
}
412
412
413
- private handleCompilerOptionsDiagnostics ( project : ts . server . Project ) {
413
+ private handleCompilerOptionsDiagnostics ( project : ts . server . Project ) : void {
414
414
if ( ! isConfiguredProject ( project ) ) {
415
415
return ;
416
416
}
@@ -572,7 +572,7 @@ export class Session {
572
572
* an inferred project.
573
573
* @param scriptInfo
574
574
*/
575
- getDefaultProjectForScriptInfo ( scriptInfo : ts . server . ScriptInfo ) : ts . server . Project | undefined {
575
+ getDefaultProjectForScriptInfo ( scriptInfo : ts . server . ScriptInfo ) : ts . server . Project | null {
576
576
let project = this . projectService . getDefaultProjectForFile (
577
577
scriptInfo . fileName ,
578
578
// ensureProject tries to find a default project for the scriptInfo if
@@ -589,11 +589,11 @@ export class Session {
589
589
if ( ! configFileName ) {
590
590
// Failed to find a config file. There is nothing we could do.
591
591
this . error ( `No config file for ${ scriptInfo . fileName } ` ) ;
592
- return ;
592
+ return null ;
593
593
}
594
594
project = this . projectService . findProject ( configFileName ) ;
595
595
if ( ! project ) {
596
- return ;
596
+ return null ;
597
597
}
598
598
scriptInfo . detachAllProjects ( ) ;
599
599
scriptInfo . attachToProject ( project ) ;
@@ -698,7 +698,7 @@ export class Session {
698
698
* Creates an external project with the same config path as `project` so that TypeScript keeps the
699
699
* project open when navigating away from `html` files.
700
700
*/
701
- private createExternalProject ( project : ts . server . Project ) {
701
+ private createExternalProject ( project : ts . server . Project ) : void {
702
702
if ( isConfiguredProject ( project ) &&
703
703
! this . configuredProjToExternalProj . has ( project . projectName ) ) {
704
704
const extProjectName = `${ project . projectName } -external` ;
@@ -727,7 +727,7 @@ export class Session {
727
727
* checks if there are no longer any open files in any external project. If there
728
728
* aren't, we also close the external project that was created.
729
729
*/
730
- private closeOrphanedExternalProjects ( ) {
730
+ private closeOrphanedExternalProjects ( ) : void {
731
731
for ( const [ configuredProjName , externalProjName ] of this . configuredProjToExternalProj ) {
732
732
const configuredProj = this . projectService . findProject ( configuredProjName ) ;
733
733
if ( ! configuredProj || configuredProj . isClosed ( ) ) {
@@ -748,7 +748,7 @@ export class Session {
748
748
}
749
749
}
750
750
751
- private onDidChangeTextDocument ( params : lsp . DidChangeTextDocumentParams ) {
751
+ private onDidChangeTextDocument ( params : lsp . DidChangeTextDocumentParams ) : void {
752
752
const { contentChanges, textDocument} = params ;
753
753
const filePath = uriToFilePath ( textDocument . uri ) ;
754
754
if ( ! filePath ) {
@@ -777,7 +777,7 @@ export class Session {
777
777
this . requestDiagnosticsOnOpenOrChangeFile ( scriptInfo . fileName , `Changing ${ filePath } ` ) ;
778
778
}
779
779
780
- private onDidSaveTextDocument ( params : lsp . DidSaveTextDocumentParams ) {
780
+ private onDidSaveTextDocument ( params : lsp . DidSaveTextDocumentParams ) : void {
781
781
const { text, textDocument} = params ;
782
782
const filePath = uriToFilePath ( textDocument . uri ) ;
783
783
if ( ! filePath ) {
@@ -795,51 +795,51 @@ export class Session {
795
795
}
796
796
}
797
797
798
- private onDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | undefined {
798
+ private onDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | null {
799
799
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
800
800
if ( lsInfo === null ) {
801
- return ;
801
+ return null ;
802
802
}
803
803
const { languageService, scriptInfo} = lsInfo ;
804
804
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
805
805
const definition = languageService . getDefinitionAndBoundSpan ( scriptInfo . fileName , offset ) ;
806
806
if ( ! definition || ! definition . definitions ) {
807
- return ;
807
+ return null ;
808
808
}
809
809
const originSelectionRange = tsTextSpanToLspRange ( scriptInfo , definition . textSpan ) ;
810
810
return this . tsDefinitionsToLspLocationLinks ( definition . definitions , originSelectionRange ) ;
811
811
}
812
812
813
- private onTypeDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | undefined {
813
+ private onTypeDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | null {
814
814
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
815
815
if ( lsInfo === null ) {
816
- return ;
816
+ return null ;
817
817
}
818
818
const { languageService, scriptInfo} = lsInfo ;
819
819
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
820
820
const definitions = languageService . getTypeDefinitionAtPosition ( scriptInfo . fileName , offset ) ;
821
821
if ( ! definitions ) {
822
- return ;
822
+ return null ;
823
823
}
824
824
return this . tsDefinitionsToLspLocationLinks ( definitions ) ;
825
825
}
826
826
827
- private onRenameRequest ( params : lsp . RenameParams ) : lsp . WorkspaceEdit | undefined {
827
+ private onRenameRequest ( params : lsp . RenameParams ) : lsp . WorkspaceEdit | null {
828
828
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
829
829
if ( lsInfo === null ) {
830
- return ;
830
+ return null ;
831
831
}
832
832
const { languageService, scriptInfo} = lsInfo ;
833
833
const project = this . getDefaultProjectForScriptInfo ( scriptInfo ) ;
834
- if ( project === undefined || this . renameDisabledProjects . has ( project ) ) {
835
- return ;
834
+ if ( project === null || this . renameDisabledProjects . has ( project ) ) {
835
+ return null ;
836
836
}
837
837
838
838
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
839
839
const renameLocations = languageService . findRenameLocations (
840
840
scriptInfo . fileName , offset , /*findInStrings*/ false , /*findInComments*/ false ) ;
841
841
if ( renameLocations === undefined ) {
842
- return ;
842
+ return null ;
843
843
}
844
844
845
845
const changes = renameLocations . reduce ( ( changes , location ) => {
@@ -869,7 +869,7 @@ export class Session {
869
869
}
870
870
const { languageService, scriptInfo} = lsInfo ;
871
871
const project = this . getDefaultProjectForScriptInfo ( scriptInfo ) ;
872
- if ( project === undefined || this . renameDisabledProjects . has ( project ) ) {
872
+ if ( project === null || this . renameDisabledProjects . has ( project ) ) {
873
873
return null ;
874
874
}
875
875
@@ -885,16 +885,16 @@ export class Session {
885
885
} ;
886
886
}
887
887
888
- private onReferences ( params : lsp . TextDocumentPositionParams ) : lsp . Location [ ] | undefined {
888
+ private onReferences ( params : lsp . TextDocumentPositionParams ) : lsp . Location [ ] | null {
889
889
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
890
890
if ( lsInfo === null ) {
891
- return ;
891
+ return null ;
892
892
}
893
893
const { languageService, scriptInfo} = lsInfo ;
894
894
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
895
895
const references = languageService . getReferencesAtPosition ( scriptInfo . fileName , offset ) ;
896
896
if ( references === undefined ) {
897
- return ;
897
+ return null ;
898
898
}
899
899
return references . map ( ref => {
900
900
const scriptInfo = this . projectService . getScriptInfo ( ref . fileName ) ;
@@ -962,16 +962,16 @@ export class Session {
962
962
} ;
963
963
}
964
964
965
- private onHover ( params : lsp . TextDocumentPositionParams ) {
965
+ private onHover ( params : lsp . TextDocumentPositionParams ) : lsp . Hover | null {
966
966
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
967
967
if ( lsInfo === null ) {
968
- return ;
968
+ return null ;
969
969
}
970
970
const { languageService, scriptInfo} = lsInfo ;
971
971
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
972
972
const info = languageService . getQuickInfoAtPosition ( scriptInfo . fileName , offset ) ;
973
973
if ( ! info ) {
974
- return ;
974
+ return null ;
975
975
}
976
976
const { kind, kindModifiers, textSpan, displayParts, documentation} = info ;
977
977
let desc = kindModifiers ? kindModifiers + ' ' : '' ;
@@ -997,10 +997,10 @@ export class Session {
997
997
} ;
998
998
}
999
999
1000
- private onCompletion ( params : lsp . CompletionParams ) {
1000
+ private onCompletion ( params : lsp . CompletionParams ) : lsp . CompletionItem [ ] | null {
1001
1001
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
1002
1002
if ( lsInfo === null ) {
1003
- return ;
1003
+ return null ;
1004
1004
}
1005
1005
const { languageService, scriptInfo} = lsInfo ;
1006
1006
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
@@ -1016,7 +1016,7 @@ export class Session {
1016
1016
const completions =
1017
1017
languageService . getCompletionsAtPosition ( scriptInfo . fileName , offset , options ) ;
1018
1018
if ( ! completions ) {
1019
- return ;
1019
+ return null ;
1020
1020
}
1021
1021
const clientSupportsInsertReplaceCompletion =
1022
1022
this . clientCapabilities . textDocument ?. completion ?. completionItem ?. insertReplaceSupport ??
@@ -1103,7 +1103,7 @@ export class Session {
1103
1103
/**
1104
1104
* Start listening on the input stream for messages to process.
1105
1105
*/
1106
- listen ( ) {
1106
+ listen ( ) : void {
1107
1107
this . connection . listen ( ) ;
1108
1108
}
1109
1109
0 commit comments