@@ -112,9 +112,9 @@ namespace ts.server {
112112 export abstract class Project implements LanguageServiceHost , ModuleResolutionHost {
113113 private rootFiles : ScriptInfo [ ] = [ ] ;
114114 private rootFilesMap : Map < ProjectRoot > = createMap < ProjectRoot > ( ) ;
115- private program : Program ;
116- private externalFiles : SortedReadonlyArray < string > ;
117- private missingFilesMap : Map < FileWatcher > ;
115+ private program : Program | undefined ;
116+ private externalFiles : SortedReadonlyArray < string > | undefined ;
117+ private missingFilesMap : Map < FileWatcher > | undefined ;
118118 private plugins : PluginModuleWithName [ ] = [ ] ;
119119
120120 /*@internal */
@@ -141,7 +141,7 @@ namespace ts.server {
141141 readonly realpath ?: ( path : string ) => string ;
142142
143143 /*@internal */
144- hasInvalidatedResolution : HasInvalidatedResolution ;
144+ hasInvalidatedResolution : HasInvalidatedResolution | undefined ;
145145
146146 /*@internal */
147147 resolutionCache : ResolutionCache ;
@@ -154,7 +154,7 @@ namespace ts.server {
154154 /**
155155 * Set of files that was returned from the last call to getChangesSinceVersion.
156156 */
157- private lastReportedFileNames : Map < true > ;
157+ private lastReportedFileNames : Map < true > | undefined ;
158158 /**
159159 * Last version that was reported.
160160 */
@@ -512,8 +512,8 @@ namespace ts.server {
512512 return [ ] ;
513513 }
514514 updateProjectIfDirty ( this ) ;
515- this . builderState = BuilderState . create ( this . program , this . projectService . toCanonicalFileName , this . builderState ) ;
516- return mapDefined ( BuilderState . getFilesAffectedBy ( this . builderState , this . program , scriptInfo . path , this . cancellationToken , data => this . projectService . host . createHash ! ( data ) ) , // TODO: GH#18217
515+ this . builderState = BuilderState . create ( this . program ! , this . projectService . toCanonicalFileName , this . builderState ) ;
516+ return mapDefined ( BuilderState . getFilesAffectedBy ( this . builderState , this . program ! , scriptInfo . path , this . cancellationToken , data => this . projectService . host . createHash ! ( data ) ) , // TODO: GH#18217
517517 sourceFile => this . shouldEmitFile ( this . projectService . getScriptInfoForPath ( sourceFile . path ) ! ) ? sourceFile . fileName : undefined ) ;
518518 }
519519
@@ -594,7 +594,7 @@ namespace ts.server {
594594
595595 /* @internal */
596596 getSourceFileOrConfigFile ( path : Path ) : SourceFile | undefined {
597- const options = this . program . getCompilerOptions ( ) ;
597+ const options = this . program ! . getCompilerOptions ( ) ;
598598 return path === options . configFilePath ? options . configFile : this . getSourceFile ( path ) ;
599599 }
600600
@@ -681,7 +681,7 @@ namespace ts.server {
681681 // if language service is not enabled - return just root files
682682 return this . rootFiles ;
683683 }
684- return map ( this . program . getSourceFiles ( ) , sourceFile => {
684+ return map ( this . program ! . getSourceFiles ( ) , sourceFile => {
685685 const scriptInfo = this . projectService . getScriptInfoForPath ( sourceFile . resolvedPath ) ;
686686 Debug . assert ( ! ! scriptInfo , "getScriptInfo" , ( ) => `scriptInfo for a file '${ sourceFile . fileName } ' Path: '${ sourceFile . path } ' / '${ sourceFile . resolvedPath } ' is missing.` ) ;
687687 return scriptInfo ! ;
@@ -749,7 +749,7 @@ namespace ts.server {
749749 }
750750
751751 containsScriptInfo ( info : ScriptInfo ) : boolean {
752- return this . isRoot ( info ) || ( this . program && this . program . getSourceFileByPath ( info . path ) !== undefined ) ;
752+ return this . isRoot ( info ) || ( ! ! this . program && this . program . getSourceFileByPath ( info . path ) !== undefined ) ;
753753 }
754754
755755 containsFile ( filename : NormalizedPath , requireOpen ?: boolean ) : boolean {
@@ -845,7 +845,7 @@ namespace ts.server {
845845 // (can reuse cached imports for files that were not changed)
846846 // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch
847847 if ( hasNewProgram || changedFiles . length ) {
848- this . lastCachedUnresolvedImportsList = getUnresolvedImports ( this . program , this . cachedUnresolvedImportsPerFile ) ;
848+ this . lastCachedUnresolvedImportsList = getUnresolvedImports ( this . program ! , this . cachedUnresolvedImportsPerFile ) ;
849849 }
850850
851851 this . projectService . typingsCache . enqueueInstallTypingsForProject ( this , this . lastCachedUnresolvedImportsList , hasAddedorRemovedFiles ) ;
@@ -872,7 +872,7 @@ namespace ts.server {
872872 }
873873
874874 /* @internal */
875- getCurrentProgram ( ) {
875+ getCurrentProgram ( ) : Program | undefined {
876876 return this . program ;
877877 }
878878
@@ -911,7 +911,7 @@ namespace ts.server {
911911 }
912912
913913 oldProgram . forEachResolvedProjectReference ( ( resolvedProjectReference , resolvedProjectReferencePath ) => {
914- if ( resolvedProjectReference && ! this . program . getResolvedProjectReferenceByPath ( resolvedProjectReferencePath ) ) {
914+ if ( resolvedProjectReference && ! this . program ! . getResolvedProjectReferenceByPath ( resolvedProjectReferencePath ) ) {
915915 this . detachScriptInfoFromProject ( resolvedProjectReference . sourceFile . fileName ) ;
916916 }
917917 } ) ;
@@ -967,8 +967,8 @@ namespace ts.server {
967967 this . getCachedDirectoryStructureHost ( ) . addOrDeleteFile ( fileName , missingFilePath , eventKind ) ;
968968 }
969969
970- if ( eventKind === FileWatcherEventKind . Created && this . missingFilesMap . has ( missingFilePath ) ) {
971- this . missingFilesMap . delete ( missingFilePath ) ;
970+ if ( eventKind === FileWatcherEventKind . Created && this . missingFilesMap ! . has ( missingFilePath ) ) {
971+ this . missingFilesMap ! . delete ( missingFilePath ) ;
972972 fileWatcher . close ( ) ;
973973
974974 // When a missing file is created, we should update the graph.
@@ -983,7 +983,7 @@ namespace ts.server {
983983 }
984984
985985 private isWatchedMissingFile ( path : Path ) {
986- return this . missingFilesMap && this . missingFilesMap . has ( path ) ;
986+ return ! ! this . missingFilesMap && this . missingFilesMap . has ( path ) ;
987987 }
988988
989989 getScriptInfoForNormalizedPath ( fileName : NormalizedPath ) : ScriptInfo | undefined {
@@ -1344,22 +1344,22 @@ namespace ts.server {
13441344 * Otherwise it will create an InferredProject.
13451345 */
13461346 export class ConfiguredProject extends Project {
1347- private typeAcquisition : TypeAcquisition ;
1347+ private typeAcquisition ! : TypeAcquisition ; // TODO: GH#18217
13481348 /* @internal */
13491349 configFileWatcher : FileWatcher | undefined ;
13501350 private directoriesWatchedForWildcards : Map < WildcardDirectoryWatcher > | undefined ;
13511351 readonly canonicalConfigFilePath : NormalizedPath ;
13521352
13531353 /* @internal */
1354- pendingReload : ConfigFileProgramReloadLevel ;
1354+ pendingReload : ConfigFileProgramReloadLevel | undefined ;
13551355 /* @internal */
13561356 pendingReloadReason : string | undefined ;
13571357
13581358 /*@internal */
13591359 configFileSpecs : ConfigFileSpecs | undefined ;
13601360
13611361 /*@internal */
1362- canConfigFileJsonReportNoInputFiles : boolean ;
1362+ canConfigFileJsonReportNoInputFiles = false ;
13631363
13641364 /** Ref count to the project when opened from external project */
13651365 private externalProjectRefCount = 0 ;
@@ -1590,7 +1590,7 @@ namespace ts.server {
15901590 */
15911591 export class ExternalProject extends Project {
15921592 excludedFiles : ReadonlyArray < NormalizedPath > = [ ] ;
1593- private typeAcquisition : TypeAcquisition ;
1593+ private typeAcquisition ! : TypeAcquisition ; // TODO: GH#18217
15941594 /*@internal */
15951595 constructor ( public externalProjectName : string ,
15961596 projectService : ProjectService ,
0 commit comments