@@ -112,9 +112,9 @@ namespace ts.server {
112
112
export abstract class Project implements LanguageServiceHost , ModuleResolutionHost {
113
113
private rootFiles : ScriptInfo [ ] = [ ] ;
114
114
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 ;
118
118
private plugins : PluginModuleWithName [ ] = [ ] ;
119
119
120
120
/*@internal */
@@ -141,7 +141,7 @@ namespace ts.server {
141
141
readonly realpath ?: ( path : string ) => string ;
142
142
143
143
/*@internal */
144
- hasInvalidatedResolution : HasInvalidatedResolution ;
144
+ hasInvalidatedResolution : HasInvalidatedResolution | undefined ;
145
145
146
146
/*@internal */
147
147
resolutionCache : ResolutionCache ;
@@ -154,7 +154,7 @@ namespace ts.server {
154
154
/**
155
155
* Set of files that was returned from the last call to getChangesSinceVersion.
156
156
*/
157
- private lastReportedFileNames : Map < true > ;
157
+ private lastReportedFileNames : Map < true > | undefined ;
158
158
/**
159
159
* Last version that was reported.
160
160
*/
@@ -512,8 +512,8 @@ namespace ts.server {
512
512
return [ ] ;
513
513
}
514
514
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
517
517
sourceFile => this . shouldEmitFile ( this . projectService . getScriptInfoForPath ( sourceFile . path ) ! ) ? sourceFile . fileName : undefined ) ;
518
518
}
519
519
@@ -594,7 +594,7 @@ namespace ts.server {
594
594
595
595
/* @internal */
596
596
getSourceFileOrConfigFile ( path : Path ) : SourceFile | undefined {
597
- const options = this . program . getCompilerOptions ( ) ;
597
+ const options = this . program ! . getCompilerOptions ( ) ;
598
598
return path === options . configFilePath ? options . configFile : this . getSourceFile ( path ) ;
599
599
}
600
600
@@ -681,7 +681,7 @@ namespace ts.server {
681
681
// if language service is not enabled - return just root files
682
682
return this . rootFiles ;
683
683
}
684
- return map ( this . program . getSourceFiles ( ) , sourceFile => {
684
+ return map ( this . program ! . getSourceFiles ( ) , sourceFile => {
685
685
const scriptInfo = this . projectService . getScriptInfoForPath ( sourceFile . resolvedPath ) ;
686
686
Debug . assert ( ! ! scriptInfo , "getScriptInfo" , ( ) => `scriptInfo for a file '${ sourceFile . fileName } ' Path: '${ sourceFile . path } ' / '${ sourceFile . resolvedPath } ' is missing.` ) ;
687
687
return scriptInfo ! ;
@@ -749,7 +749,7 @@ namespace ts.server {
749
749
}
750
750
751
751
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 ) ;
753
753
}
754
754
755
755
containsFile ( filename : NormalizedPath , requireOpen ?: boolean ) : boolean {
@@ -845,7 +845,7 @@ namespace ts.server {
845
845
// (can reuse cached imports for files that were not changed)
846
846
// 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch
847
847
if ( hasNewProgram || changedFiles . length ) {
848
- this . lastCachedUnresolvedImportsList = getUnresolvedImports ( this . program , this . cachedUnresolvedImportsPerFile ) ;
848
+ this . lastCachedUnresolvedImportsList = getUnresolvedImports ( this . program ! , this . cachedUnresolvedImportsPerFile ) ;
849
849
}
850
850
851
851
this . projectService . typingsCache . enqueueInstallTypingsForProject ( this , this . lastCachedUnresolvedImportsList , hasAddedorRemovedFiles ) ;
@@ -872,7 +872,7 @@ namespace ts.server {
872
872
}
873
873
874
874
/* @internal */
875
- getCurrentProgram ( ) {
875
+ getCurrentProgram ( ) : Program | undefined {
876
876
return this . program ;
877
877
}
878
878
@@ -911,7 +911,7 @@ namespace ts.server {
911
911
}
912
912
913
913
oldProgram . forEachResolvedProjectReference ( ( resolvedProjectReference , resolvedProjectReferencePath ) => {
914
- if ( resolvedProjectReference && ! this . program . getResolvedProjectReferenceByPath ( resolvedProjectReferencePath ) ) {
914
+ if ( resolvedProjectReference && ! this . program ! . getResolvedProjectReferenceByPath ( resolvedProjectReferencePath ) ) {
915
915
this . detachScriptInfoFromProject ( resolvedProjectReference . sourceFile . fileName ) ;
916
916
}
917
917
} ) ;
@@ -967,8 +967,8 @@ namespace ts.server {
967
967
this . getCachedDirectoryStructureHost ( ) . addOrDeleteFile ( fileName , missingFilePath , eventKind ) ;
968
968
}
969
969
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 ) ;
972
972
fileWatcher . close ( ) ;
973
973
974
974
// When a missing file is created, we should update the graph.
@@ -983,7 +983,7 @@ namespace ts.server {
983
983
}
984
984
985
985
private isWatchedMissingFile ( path : Path ) {
986
- return this . missingFilesMap && this . missingFilesMap . has ( path ) ;
986
+ return ! ! this . missingFilesMap && this . missingFilesMap . has ( path ) ;
987
987
}
988
988
989
989
getScriptInfoForNormalizedPath ( fileName : NormalizedPath ) : ScriptInfo | undefined {
@@ -1344,22 +1344,22 @@ namespace ts.server {
1344
1344
* Otherwise it will create an InferredProject.
1345
1345
*/
1346
1346
export class ConfiguredProject extends Project {
1347
- private typeAcquisition : TypeAcquisition ;
1347
+ private typeAcquisition ! : TypeAcquisition ; // TODO: GH#18217
1348
1348
/* @internal */
1349
1349
configFileWatcher : FileWatcher | undefined ;
1350
1350
private directoriesWatchedForWildcards : Map < WildcardDirectoryWatcher > | undefined ;
1351
1351
readonly canonicalConfigFilePath : NormalizedPath ;
1352
1352
1353
1353
/* @internal */
1354
- pendingReload : ConfigFileProgramReloadLevel ;
1354
+ pendingReload : ConfigFileProgramReloadLevel | undefined ;
1355
1355
/* @internal */
1356
1356
pendingReloadReason : string | undefined ;
1357
1357
1358
1358
/*@internal */
1359
1359
configFileSpecs : ConfigFileSpecs | undefined ;
1360
1360
1361
1361
/*@internal */
1362
- canConfigFileJsonReportNoInputFiles : boolean ;
1362
+ canConfigFileJsonReportNoInputFiles = false ;
1363
1363
1364
1364
/** Ref count to the project when opened from external project */
1365
1365
private externalProjectRefCount = 0 ;
@@ -1590,7 +1590,7 @@ namespace ts.server {
1590
1590
*/
1591
1591
export class ExternalProject extends Project {
1592
1592
excludedFiles : ReadonlyArray < NormalizedPath > = [ ] ;
1593
- private typeAcquisition : TypeAcquisition ;
1593
+ private typeAcquisition ! : TypeAcquisition ; // TODO: GH#18217
1594
1594
/*@internal */
1595
1595
constructor ( public externalProjectName : string ,
1596
1596
projectService : ProjectService ,
0 commit comments