4
4
5
5
namespace ts {
6
6
export type DiagnosticReporter = ( diagnostic : Diagnostic ) => void ;
7
- export type ParseConfigFile = ( configFileName : string , optionsToExtend : CompilerOptions , system : PartialSystem , reportDiagnostic : DiagnosticReporter , reportWatchDiagnostic : DiagnosticReporter ) => ParsedCommandLine ;
7
+ export type ParseConfigFile = ( configFileName : string , optionsToExtend : CompilerOptions , system : DirectoryStructureHost , reportDiagnostic : DiagnosticReporter , reportWatchDiagnostic : DiagnosticReporter ) => ParsedCommandLine ;
8
8
export interface WatchingSystemHost {
9
9
// FS system to use
10
10
system : System ;
@@ -18,7 +18,7 @@ namespace ts {
18
18
19
19
// Callbacks to do custom action before creating program and after creating program
20
20
beforeCompile ( compilerOptions : CompilerOptions ) : void ;
21
- afterCompile ( host : PartialSystem , program : Program , builder : Builder ) : void ;
21
+ afterCompile ( host : DirectoryStructureHost , program : Program , builder : Builder ) : void ;
22
22
}
23
23
24
24
const defaultFormatDiagnosticsHost : FormatDiagnosticsHost = sys ? {
@@ -61,7 +61,7 @@ namespace ts {
61
61
system . write ( ts . formatDiagnosticsWithColorAndContext ( [ diagnostic ] , host ) + host . getNewLine ( ) ) ;
62
62
}
63
63
64
- export function parseConfigFile ( configFileName : string , optionsToExtend : CompilerOptions , system : PartialSystem , reportDiagnostic : DiagnosticReporter , reportWatchDiagnostic : DiagnosticReporter ) : ParsedCommandLine {
64
+ export function parseConfigFile ( configFileName : string , optionsToExtend : CompilerOptions , system : DirectoryStructureHost , reportDiagnostic : DiagnosticReporter , reportWatchDiagnostic : DiagnosticReporter ) : ParsedCommandLine {
65
65
let configFileText : string ;
66
66
try {
67
67
configFileText = system . readFile ( configFileName ) ;
@@ -89,7 +89,7 @@ namespace ts {
89
89
return configParseResult ;
90
90
}
91
91
92
- function reportEmittedFiles ( files : string [ ] , system : PartialSystem ) : void {
92
+ function reportEmittedFiles ( files : string [ ] , system : DirectoryStructureHost ) : void {
93
93
if ( ! files || files . length === 0 ) {
94
94
return ;
95
95
}
@@ -100,7 +100,7 @@ namespace ts {
100
100
}
101
101
}
102
102
103
- export function handleEmitOutputAndReportErrors ( system : PartialSystem , program : Program ,
103
+ export function handleEmitOutputAndReportErrors ( system : DirectoryStructureHost , program : Program ,
104
104
emittedFiles : string [ ] , emitSkipped : boolean ,
105
105
diagnostics : Diagnostic [ ] , reportDiagnostic : DiagnosticReporter
106
106
) : ExitStatus {
@@ -141,7 +141,7 @@ namespace ts {
141
141
afterCompile : compileWatchedProgram ,
142
142
} ;
143
143
144
- function compileWatchedProgram ( host : PartialSystem , program : Program , builder : Builder ) {
144
+ function compileWatchedProgram ( host : DirectoryStructureHost , program : Program , builder : Builder ) {
145
145
// First get and report any syntactic errors.
146
146
let diagnostics = program . getSyntacticDiagnostics ( ) . slice ( ) ;
147
147
let reportSemanticDiagnostics = false ;
@@ -256,14 +256,14 @@ namespace ts {
256
256
watchingHost = watchingHost || createWatchingSystemHost ( compilerOptions . pretty ) ;
257
257
const { system, parseConfigFile, reportDiagnostic, reportWatchDiagnostic, beforeCompile, afterCompile } = watchingHost ;
258
258
259
- const partialSystem = configFileName ? createCachedPartialSystem ( system ) : system ;
259
+ const directoryStructureHost = configFileName ? createCachedDirectoryStructureHost ( system ) : system ;
260
260
if ( configFileName ) {
261
261
watchFile ( system , configFileName , scheduleProgramReload , writeLog ) ;
262
262
}
263
263
264
- const getCurrentDirectory = memoize ( ( ) => partialSystem . getCurrentDirectory ( ) ) ;
264
+ const getCurrentDirectory = memoize ( ( ) => directoryStructureHost . getCurrentDirectory ( ) ) ;
265
265
const realpath = system . realpath && ( ( path : string ) => system . realpath ( path ) ) ;
266
- const getCachedPartialSystem = configFileName && ( ( ) => partialSystem as CachedPartialSystem ) ;
266
+ const getCachedDirectoryStructureHost = configFileName && ( ( ) => directoryStructureHost as CachedDirectoryStructureHost ) ;
267
267
const getCanonicalFileName = createGetCanonicalFileName ( system . useCaseSensitiveFileNames ) ;
268
268
let newLine = getNewLineCharacter ( compilerOptions , system ) ;
269
269
@@ -294,7 +294,7 @@ namespace ts {
294
294
getCompilationSettings : ( ) => compilerOptions ,
295
295
watchDirectoryOfFailedLookupLocation : watchDirectory ,
296
296
watchTypeRootsDirectory : watchDirectory ,
297
- getCachedPartialSystem ,
297
+ getCachedDirectoryStructureHost ,
298
298
onInvalidatedResolution : scheduleProgramUpdate ,
299
299
onChangedAutomaticTypeDirectiveNames,
300
300
writeLog
@@ -361,7 +361,7 @@ namespace ts {
361
361
missingFilePathsRequestedForRelease = undefined ;
362
362
}
363
363
364
- afterCompile ( partialSystem , program , builder ) ;
364
+ afterCompile ( directoryStructureHost , program , builder ) ;
365
365
reportWatchDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) ) ;
366
366
}
367
367
@@ -376,11 +376,11 @@ namespace ts {
376
376
return ! isString ( hostSourceFileInfo ) ;
377
377
}
378
378
379
- return partialSystem . fileExists ( fileName ) ;
379
+ return directoryStructureHost . fileExists ( fileName ) ;
380
380
}
381
381
382
382
function directoryExists ( directoryName : string ) {
383
- return partialSystem . directoryExists ( directoryName ) ;
383
+ return directoryStructureHost . directoryExists ( directoryName ) ;
384
384
}
385
385
386
386
function readFile ( fileName : string ) {
@@ -392,7 +392,7 @@ namespace ts {
392
392
}
393
393
394
394
function getDirectories ( path : string ) {
395
- return partialSystem . getDirectories ( path ) ;
395
+ return directoryStructureHost . getDirectories ( path ) ;
396
396
}
397
397
398
398
function resolveModuleNames ( moduleNames : string [ ] , containingFile : string , reusedNames ?: string [ ] ) {
@@ -541,7 +541,7 @@ namespace ts {
541
541
writeLog ( `Reloading config file: ${ configFileName } ` ) ;
542
542
needsReload = false ;
543
543
544
- const cachedHost = partialSystem as CachedPartialSystem ;
544
+ const cachedHost = directoryStructureHost as CachedDirectoryStructureHost ;
545
545
cachedHost . clearCache ( ) ;
546
546
const configParseResult = parseConfigFile ( configFileName , optionsToExtendForConfigFile , cachedHost , reportDiagnostic , reportWatchDiagnostic ) ;
547
547
rootFileNames = configParseResult . fileNames ;
@@ -586,7 +586,7 @@ namespace ts {
586
586
587
587
function updateCachedSystemWithFile ( fileName : string , path : Path , eventKind : FileWatcherEventKind ) {
588
588
if ( configFileName ) {
589
- ( partialSystem as CachedPartialSystem ) . addOrDeleteFile ( fileName , path , eventKind ) ;
589
+ ( directoryStructureHost as CachedDirectoryStructureHost ) . addOrDeleteFile ( fileName , path , eventKind ) ;
590
590
}
591
591
}
592
592
@@ -639,7 +639,7 @@ namespace ts {
639
639
const fileOrFolderPath = toPath ( fileOrFolder ) ;
640
640
641
641
// Since the file existance changed, update the sourceFiles cache
642
- ( partialSystem as CachedPartialSystem ) . addOrDeleteFileOrFolder ( fileOrFolder , fileOrFolderPath ) ;
642
+ ( directoryStructureHost as CachedDirectoryStructureHost ) . addOrDeleteFileOrFolder ( fileOrFolder , fileOrFolderPath ) ;
643
643
removeSourceFile ( fileOrFolderPath ) ;
644
644
645
645
// If the the added or created file or folder is not supported file name, ignore the file
@@ -651,7 +651,7 @@ namespace ts {
651
651
652
652
// Reload is pending, do the reload
653
653
if ( ! needsReload ) {
654
- const result = getFileNamesFromConfigSpecs ( configFileSpecs , getDirectoryPath ( configFileName ) , compilerOptions , partialSystem ) ;
654
+ const result = getFileNamesFromConfigSpecs ( configFileSpecs , getDirectoryPath ( configFileName ) , compilerOptions , directoryStructureHost ) ;
655
655
if ( ! configFileSpecs . filesSpecs && result . fileNames . length === 0 ) {
656
656
reportDiagnostic ( getErrorForNoInputFiles ( configFileSpecs , configFileName ) ) ;
657
657
}
0 commit comments