@@ -332,7 +332,7 @@ export class Session {
332
332
return params ;
333
333
}
334
334
335
- private enableLanguageServiceForProject ( project : ts . server . Project ) {
335
+ private enableLanguageServiceForProject ( project : ts . server . Project ) : void {
336
336
const { projectName} = project ;
337
337
if ( project . isClosed ( ) ) {
338
338
this . info ( `Cannot enable language service for closed project ${ projectName } .` ) ;
@@ -359,7 +359,7 @@ export class Session {
359
359
this . runGlobalAnalysisForNewlyLoadedProject ( project ) ;
360
360
}
361
361
362
- private disableLanguageServiceForProject ( project : ts . server . Project , reason : string ) {
362
+ private disableLanguageServiceForProject ( project : ts . server . Project , reason : string ) : void {
363
363
if ( ! project . languageServiceEnabled ) {
364
364
return ;
365
365
}
@@ -372,7 +372,7 @@ export class Session {
372
372
* Invoke the compiler for the first time so that external templates get
373
373
* matched to the project they belong to.
374
374
*/
375
- private runGlobalAnalysisForNewlyLoadedProject ( project : ts . server . Project ) {
375
+ private runGlobalAnalysisForNewlyLoadedProject ( project : ts . server . Project ) : void {
376
376
if ( ! project . hasRoots ( ) ) {
377
377
return ;
378
378
}
@@ -388,7 +388,7 @@ export class Session {
388
388
}
389
389
}
390
390
391
- private handleCompilerOptionsDiagnostics ( project : ts . server . Project ) {
391
+ private handleCompilerOptionsDiagnostics ( project : ts . server . Project ) : void {
392
392
if ( ! isConfiguredProject ( project ) ) {
393
393
return ;
394
394
}
@@ -550,7 +550,7 @@ export class Session {
550
550
* an inferred project.
551
551
* @param scriptInfo
552
552
*/
553
- getDefaultProjectForScriptInfo ( scriptInfo : ts . server . ScriptInfo ) : ts . server . Project | undefined {
553
+ getDefaultProjectForScriptInfo ( scriptInfo : ts . server . ScriptInfo ) : ts . server . Project | null {
554
554
let project = this . projectService . getDefaultProjectForFile (
555
555
scriptInfo . fileName ,
556
556
// ensureProject tries to find a default project for the scriptInfo if
@@ -567,11 +567,11 @@ export class Session {
567
567
if ( ! configFileName ) {
568
568
// Failed to find a config file. There is nothing we could do.
569
569
this . error ( `No config file for ${ scriptInfo . fileName } ` ) ;
570
- return ;
570
+ return null ;
571
571
}
572
572
project = this . projectService . findProject ( configFileName ) ;
573
573
if ( ! project ) {
574
- return ;
574
+ return null ;
575
575
}
576
576
scriptInfo . detachAllProjects ( ) ;
577
577
scriptInfo . attachToProject ( project ) ;
@@ -676,7 +676,7 @@ export class Session {
676
676
* Creates an external project with the same config path as `project` so that TypeScript keeps the
677
677
* project open when navigating away from `html` files.
678
678
*/
679
- private createExternalProject ( project : ts . server . Project ) {
679
+ private createExternalProject ( project : ts . server . Project ) : void {
680
680
if ( isConfiguredProject ( project ) &&
681
681
! this . configuredProjToExternalProj . has ( project . projectName ) ) {
682
682
const extProjectName = `${ project . projectName } -external` ;
@@ -705,7 +705,7 @@ export class Session {
705
705
* checks if there are no longer any open files in any external project. If there
706
706
* aren't, we also close the external project that was created.
707
707
*/
708
- private closeOrphanedExternalProjects ( ) {
708
+ private closeOrphanedExternalProjects ( ) : void {
709
709
for ( const [ configuredProjName , externalProjName ] of this . configuredProjToExternalProj ) {
710
710
const configuredProj = this . projectService . findProject ( configuredProjName ) ;
711
711
if ( ! configuredProj || configuredProj . isClosed ( ) ) {
@@ -726,7 +726,7 @@ export class Session {
726
726
}
727
727
}
728
728
729
- private onDidChangeTextDocument ( params : lsp . DidChangeTextDocumentParams ) {
729
+ private onDidChangeTextDocument ( params : lsp . DidChangeTextDocumentParams ) : void {
730
730
const { contentChanges, textDocument} = params ;
731
731
const filePath = uriToFilePath ( textDocument . uri ) ;
732
732
if ( ! filePath ) {
@@ -755,7 +755,7 @@ export class Session {
755
755
this . requestDiagnosticsOnOpenOrChangeFile ( scriptInfo . fileName , `Changing ${ filePath } ` ) ;
756
756
}
757
757
758
- private onDidSaveTextDocument ( params : lsp . DidSaveTextDocumentParams ) {
758
+ private onDidSaveTextDocument ( params : lsp . DidSaveTextDocumentParams ) : void {
759
759
const { text, textDocument} = params ;
760
760
const filePath = uriToFilePath ( textDocument . uri ) ;
761
761
if ( ! filePath ) {
@@ -773,51 +773,51 @@ export class Session {
773
773
}
774
774
}
775
775
776
- private onDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | undefined {
776
+ private onDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | null {
777
777
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
778
778
if ( lsInfo === null ) {
779
- return ;
779
+ return null ;
780
780
}
781
781
const { languageService, scriptInfo} = lsInfo ;
782
782
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
783
783
const definition = languageService . getDefinitionAndBoundSpan ( scriptInfo . fileName , offset ) ;
784
784
if ( ! definition || ! definition . definitions ) {
785
- return ;
785
+ return null ;
786
786
}
787
787
const originSelectionRange = tsTextSpanToLspRange ( scriptInfo , definition . textSpan ) ;
788
788
return this . tsDefinitionsToLspLocationLinks ( definition . definitions , originSelectionRange ) ;
789
789
}
790
790
791
- private onTypeDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | undefined {
791
+ private onTypeDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | null {
792
792
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
793
793
if ( lsInfo === null ) {
794
- return ;
794
+ return null ;
795
795
}
796
796
const { languageService, scriptInfo} = lsInfo ;
797
797
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
798
798
const definitions = languageService . getTypeDefinitionAtPosition ( scriptInfo . fileName , offset ) ;
799
799
if ( ! definitions ) {
800
- return ;
800
+ return null ;
801
801
}
802
802
return this . tsDefinitionsToLspLocationLinks ( definitions ) ;
803
803
}
804
804
805
- private onRenameRequest ( params : lsp . RenameParams ) : lsp . WorkspaceEdit | undefined {
805
+ private onRenameRequest ( params : lsp . RenameParams ) : lsp . WorkspaceEdit | null {
806
806
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
807
807
if ( lsInfo === null ) {
808
- return ;
808
+ return null ;
809
809
}
810
810
const { languageService, scriptInfo} = lsInfo ;
811
811
const project = this . getDefaultProjectForScriptInfo ( scriptInfo ) ;
812
- if ( project === undefined || this . renameDisabledProjects . has ( project ) ) {
813
- return ;
812
+ if ( project === null || this . renameDisabledProjects . has ( project ) ) {
813
+ return null ;
814
814
}
815
815
816
816
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
817
817
const renameLocations = languageService . findRenameLocations (
818
818
scriptInfo . fileName , offset , /*findInStrings*/ false , /*findInComments*/ false ) ;
819
819
if ( renameLocations === undefined ) {
820
- return ;
820
+ return null ;
821
821
}
822
822
823
823
const changes = renameLocations . reduce ( ( changes , location ) => {
@@ -847,7 +847,7 @@ export class Session {
847
847
}
848
848
const { languageService, scriptInfo} = lsInfo ;
849
849
const project = this . getDefaultProjectForScriptInfo ( scriptInfo ) ;
850
- if ( project === undefined || this . renameDisabledProjects . has ( project ) ) {
850
+ if ( project === null || this . renameDisabledProjects . has ( project ) ) {
851
851
return null ;
852
852
}
853
853
@@ -863,16 +863,16 @@ export class Session {
863
863
} ;
864
864
}
865
865
866
- private onReferences ( params : lsp . TextDocumentPositionParams ) : lsp . Location [ ] | undefined {
866
+ private onReferences ( params : lsp . TextDocumentPositionParams ) : lsp . Location [ ] | null {
867
867
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
868
868
if ( lsInfo === null ) {
869
- return ;
869
+ return null ;
870
870
}
871
871
const { languageService, scriptInfo} = lsInfo ;
872
872
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
873
873
const references = languageService . getReferencesAtPosition ( scriptInfo . fileName , offset ) ;
874
874
if ( references === undefined ) {
875
- return ;
875
+ return null ;
876
876
}
877
877
return references . map ( ref => {
878
878
const scriptInfo = this . projectService . getScriptInfo ( ref . fileName ) ;
@@ -940,16 +940,16 @@ export class Session {
940
940
} ;
941
941
}
942
942
943
- private onHover ( params : lsp . TextDocumentPositionParams ) {
943
+ private onHover ( params : lsp . TextDocumentPositionParams ) : lsp . Hover | null {
944
944
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
945
945
if ( lsInfo === null ) {
946
- return ;
946
+ return null ;
947
947
}
948
948
const { languageService, scriptInfo} = lsInfo ;
949
949
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
950
950
const info = languageService . getQuickInfoAtPosition ( scriptInfo . fileName , offset ) ;
951
951
if ( ! info ) {
952
- return ;
952
+ return null ;
953
953
}
954
954
const { kind, kindModifiers, textSpan, displayParts, documentation} = info ;
955
955
let desc = kindModifiers ? kindModifiers + ' ' : '' ;
@@ -975,10 +975,10 @@ export class Session {
975
975
} ;
976
976
}
977
977
978
- private onCompletion ( params : lsp . CompletionParams ) {
978
+ private onCompletion ( params : lsp . CompletionParams ) : lsp . CompletionItem [ ] | null {
979
979
const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
980
980
if ( lsInfo === null ) {
981
- return ;
981
+ return null ;
982
982
}
983
983
const { languageService, scriptInfo} = lsInfo ;
984
984
const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
@@ -994,7 +994,7 @@ export class Session {
994
994
const completions =
995
995
languageService . getCompletionsAtPosition ( scriptInfo . fileName , offset , options ) ;
996
996
if ( ! completions ) {
997
- return ;
997
+ return null ;
998
998
}
999
999
const clientSupportsInsertReplaceCompletion =
1000
1000
this . clientCapabilities . textDocument ?. completion ?. completionItem ?. insertReplaceSupport ??
@@ -1081,7 +1081,7 @@ export class Session {
1081
1081
/**
1082
1082
* Start listening on the input stream for messages to process.
1083
1083
*/
1084
- listen ( ) {
1084
+ listen ( ) : void {
1085
1085
this . connection . listen ( ) ;
1086
1086
}
1087
1087
0 commit comments