@@ -175,42 +175,42 @@ export class Session {
175175 conn . onSignatureHelp ( p => this . onSignatureHelp ( p ) ) ;
176176 }
177177
178- private isInAngularProject ( params : IsInAngularProjectParams ) : boolean | undefined {
178+ private isInAngularProject ( params : IsInAngularProjectParams ) : boolean | null {
179179 const filePath = uriToFilePath ( params . textDocument . uri ) ;
180180 if ( ! filePath ) {
181181 return false ;
182182 }
183183 const lsAndScriptInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
184184 if ( ! lsAndScriptInfo ) {
185- // If we cannot get language service / script info, return undefined to indicate we don't know
185+ // If we cannot get language service / script info, return null to indicate we don't know
186186 // the answer definitively.
187- return undefined ;
187+ return null ;
188188 }
189189 const project = this . getDefaultProjectForScriptInfo ( lsAndScriptInfo . scriptInfo ) ;
190190 if ( ! project ) {
191- // If we cannot get project, return undefined to indicate we don't know
191+ // If we cannot get project, return null to indicate we don't know
192192 // the answer definitively.
193- return undefined ;
193+ return null ;
194194 }
195195 const angularCore = project . getFileNames ( ) . find ( isAngularCore ) ;
196196 return angularCore !== undefined ;
197197 }
198198
199- private onGetTcb ( params : GetTcbParams ) : GetTcbResponse | undefined {
199+ private onGetTcb ( params : GetTcbParams ) : GetTcbResponse | null {
200200 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
201- if ( lsInfo === undefined ) {
202- return undefined ;
201+ if ( lsInfo === null ) {
202+ return null ;
203203 }
204204 const { languageService, scriptInfo} = lsInfo ;
205205 const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
206206 const response = languageService . getTcb ( scriptInfo . fileName , offset ) ;
207207 if ( response === undefined ) {
208- return undefined ;
208+ return null ;
209209 }
210210 const { fileName : tcfName } = response ;
211211 const tcfScriptInfo = this . projectService . getScriptInfo ( tcfName ) ;
212212 if ( ! tcfScriptInfo ) {
213- return undefined ;
213+ return null ;
214214 }
215215 return {
216216 uri : filePathToUri ( tcfName ) ,
@@ -219,10 +219,10 @@ export class Session {
219219 } ;
220220 }
221221
222- private onGetComponentsWithTemplateFile ( params : any ) : lsp . Location [ ] | undefined {
222+ private onGetComponentsWithTemplateFile ( params : any ) : lsp . Location [ ] | null {
223223 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
224- if ( lsInfo === undefined ) {
225- return undefined ;
224+ if ( lsInfo === null ) {
225+ return null ;
226226 }
227227 const { languageService, scriptInfo} = lsInfo ;
228228 const documentSpans = languageService . getComponentLocationsForTemplate ( scriptInfo . fileName ) ;
@@ -238,18 +238,18 @@ export class Session {
238238 return results ;
239239 }
240240
241- private onSignatureHelp ( params : lsp . SignatureHelpParams ) : lsp . SignatureHelp | undefined {
241+ private onSignatureHelp ( params : lsp . SignatureHelpParams ) : lsp . SignatureHelp | null {
242242 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
243- if ( lsInfo === undefined ) {
244- return undefined ;
243+ if ( lsInfo === null ) {
244+ return null ;
245245 }
246246
247247 const { languageService, scriptInfo} = lsInfo ;
248248 const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
249249
250250 const help = languageService . getSignatureHelpItems ( scriptInfo . fileName , offset , undefined ) ;
251251 if ( help === undefined ) {
252- return undefined ;
252+ return null ;
253253 }
254254
255255 return {
@@ -289,9 +289,9 @@ export class Session {
289289 } ;
290290 }
291291
292- private onCodeLens ( params : lsp . CodeLensParams ) : lsp . CodeLens [ ] | undefined {
292+ private onCodeLens ( params : lsp . CodeLensParams ) : lsp . CodeLens [ ] | null {
293293 if ( ! params . textDocument . uri . endsWith ( '.html' ) || ! this . isInAngularProject ( params ) ) {
294- return undefined ;
294+ return null ;
295295 }
296296 const position = lsp . Position . create ( 0 , 0 ) ;
297297 const topOfDocument = lsp . Range . create ( position , position ) ;
@@ -307,7 +307,7 @@ export class Session {
307307
308308 private onCodeLensResolve ( params : lsp . CodeLens ) : lsp . CodeLens {
309309 const components = this . onGetComponentsWithTemplateFile ( { textDocument : params . data } ) ;
310- if ( components === undefined || components . length === 0 ) {
310+ if ( components === null || components . length === 0 ) {
311311 // While the command is supposed to be optional, vscode will show `!!MISSING: command!!` that
312312 // fails if you click on it when a command is not provided. Instead, throwing an error will
313313 // make vscode show the text "no commands" (and it's not a link).
@@ -752,7 +752,7 @@ export class Session {
752752
753753 private onDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | undefined {
754754 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
755- if ( lsInfo === undefined ) {
755+ if ( lsInfo === null ) {
756756 return ;
757757 }
758758 const { languageService, scriptInfo} = lsInfo ;
@@ -767,7 +767,7 @@ export class Session {
767767
768768 private onTypeDefinition ( params : lsp . TextDocumentPositionParams ) : lsp . LocationLink [ ] | undefined {
769769 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
770- if ( lsInfo === undefined ) {
770+ if ( lsInfo === null ) {
771771 return ;
772772 }
773773 const { languageService, scriptInfo} = lsInfo ;
@@ -781,7 +781,7 @@ export class Session {
781781
782782 private onRenameRequest ( params : lsp . RenameParams ) : lsp . WorkspaceEdit | undefined {
783783 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
784- if ( lsInfo === undefined ) {
784+ if ( lsInfo === null ) {
785785 return ;
786786 }
787787 const { languageService, scriptInfo} = lsInfo ;
@@ -804,7 +804,7 @@ export class Session {
804804 const fileEdits = changes [ location . fileName ] ;
805805
806806 const lsInfo = this . getLSAndScriptInfo ( location . fileName ) ;
807- if ( lsInfo === undefined ) {
807+ if ( lsInfo === null ) {
808808 return changes ;
809809 }
810810 const range = tsTextSpanToLspRange ( lsInfo . scriptInfo , location . textSpan ) ;
@@ -816,21 +816,21 @@ export class Session {
816816 }
817817
818818 private onPrepareRename ( params : lsp . PrepareRenameParams ) :
819- { range : lsp . Range , placeholder : string } | undefined {
819+ { range : lsp . Range , placeholder : string } | null {
820820 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
821- if ( lsInfo === undefined ) {
822- return ;
821+ if ( lsInfo === null ) {
822+ return null ;
823823 }
824824 const { languageService, scriptInfo} = lsInfo ;
825825 const project = this . getDefaultProjectForScriptInfo ( scriptInfo ) ;
826826 if ( project === undefined || this . renameDisabledProjects . has ( project ) ) {
827- return ;
827+ return null ;
828828 }
829829
830830 const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
831831 const renameInfo = languageService . getRenameInfo ( scriptInfo . fileName , offset ) ;
832832 if ( ! renameInfo . canRename ) {
833- return undefined ;
833+ return null ;
834834 }
835835 const range = tsTextSpanToLspRange ( scriptInfo , renameInfo . triggerSpan ) ;
836836 return {
@@ -841,7 +841,7 @@ export class Session {
841841
842842 private onReferences ( params : lsp . TextDocumentPositionParams ) : lsp . Location [ ] | undefined {
843843 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
844- if ( lsInfo === undefined ) {
844+ if ( lsInfo === null ) {
845845 return ;
846846 }
847847 const { languageService, scriptInfo} = lsInfo ;
@@ -887,28 +887,28 @@ export class Session {
887887 }
888888
889889 private getLSAndScriptInfo ( textDocumentOrFileName : lsp . TextDocumentIdentifier | string ) :
890- { languageService : NgLanguageService , scriptInfo : ts . server . ScriptInfo } | undefined {
890+ { languageService : NgLanguageService , scriptInfo : ts . server . ScriptInfo } | null {
891891 const filePath = lsp . TextDocumentIdentifier . is ( textDocumentOrFileName ) ?
892892 uriToFilePath ( textDocumentOrFileName . uri ) :
893893 textDocumentOrFileName ;
894894 const scriptInfo = this . projectService . getScriptInfo ( filePath ) ;
895895 if ( ! scriptInfo ) {
896896 this . error ( `Script info not found for ${ filePath } ` ) ;
897- return ;
897+ return null ;
898898 }
899899
900900 const project = this . getDefaultProjectForScriptInfo ( scriptInfo ) ;
901901 if ( ! project ?. languageServiceEnabled ) {
902- return ;
902+ return null ;
903903 }
904904 if ( project . isClosed ( ) ) {
905905 scriptInfo . detachFromProject ( project ) ;
906906 this . logger . info ( `Failed to get language service for closed project ${ project . projectName } .` ) ;
907- return undefined ;
907+ return null ;
908908 }
909909 const languageService = project . getLanguageService ( ) ;
910910 if ( ! isNgLanguageService ( languageService ) ) {
911- return undefined ;
911+ return null ;
912912 }
913913 return {
914914 languageService,
@@ -918,7 +918,7 @@ export class Session {
918918
919919 private onHover ( params : lsp . TextDocumentPositionParams ) {
920920 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
921- if ( lsInfo === undefined ) {
921+ if ( lsInfo === null ) {
922922 return ;
923923 }
924924 const { languageService, scriptInfo} = lsInfo ;
@@ -953,7 +953,7 @@ export class Session {
953953
954954 private onCompletion ( params : lsp . CompletionParams ) {
955955 const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
956- if ( lsInfo === undefined ) {
956+ if ( lsInfo === null ) {
957957 return ;
958958 }
959959 const { languageService, scriptInfo} = lsInfo ;
@@ -980,7 +980,7 @@ export class Session {
980980
981981 const { filePath, position} = data ;
982982 const lsInfo = this . getLSAndScriptInfo ( filePath ) ;
983- if ( lsInfo === undefined ) {
983+ if ( lsInfo === null ) {
984984 return item ;
985985 }
986986 const { languageService, scriptInfo} = lsInfo ;
@@ -1056,25 +1056,25 @@ export class Session {
10561056 *
10571057 * @returns main declaration file in `@angular/core`.
10581058 */
1059- private findAngularCore ( project : ts . server . Project ) : string | undefined {
1059+ private findAngularCore ( project : ts . server . Project ) : string | null {
10601060 const { projectName} = project ;
10611061 if ( ! project . languageServiceEnabled ) {
10621062 this . info (
10631063 `Language service is already disabled for ${ projectName } . ` +
10641064 `This could be due to non-TS files that exceeded the size limit (${
10651065 ts . server . maxProgramSizeForNonTsFiles } bytes).` +
10661066 `Please check log file for details.` ) ;
1067- return ;
1067+ return null ;
10681068 }
10691069 if ( ! project . hasRoots ( ) || project . isNonTsProject ( ) ) {
1070- return undefined ;
1070+ return null ;
10711071 }
10721072 const angularCore = project . getFileNames ( ) . find ( isAngularCore ) ;
10731073 if ( angularCore === undefined && project . getExcludedFiles ( ) . some ( isAngularCore ) ) {
10741074 this . info (
10751075 `Please check your tsconfig.json to make sure 'node_modules' directory is not excluded.` ) ;
10761076 }
1077- return angularCore ;
1077+ return angularCore ?? null ;
10781078 }
10791079
10801080 /**
0 commit comments