1
1
namespace ts {
2
- export type AffectedFileResult < T > = { result : T ; affected : SourceFile | Program ; } | undefined ;
2
+ export type AffectedFileResult < T > = {
3
+ result : T ;
4
+ affected : ts . SourceFile | ts . Program ;
5
+ } | undefined ;
3
6
4
7
export interface BuilderProgramHost {
5
8
/**
@@ -14,7 +17,7 @@ namespace ts {
14
17
* When emit or emitNextAffectedFile are called without writeFile,
15
18
* this callback if present would be used to write files
16
19
*/
17
- writeFile ?: WriteFileCallback ;
20
+ writeFile ?: ts . WriteFileCallback ;
18
21
/**
19
22
* disable using source file version as signature for testing
20
23
*/
@@ -32,20 +35,20 @@ namespace ts {
32
35
*/
33
36
export interface BuilderProgram {
34
37
/*@internal */
35
- getState ( ) : ReusableBuilderProgramState ;
38
+ getState ( ) : ts . ReusableBuilderProgramState ;
36
39
/*@internal */
37
40
backupState ( ) : void ;
38
41
/*@internal */
39
42
restoreState ( ) : void ;
40
43
/**
41
44
* Returns current program
42
45
*/
43
- getProgram ( ) : Program ;
46
+ getProgram ( ) : ts . Program ;
44
47
/**
45
48
* Returns current program that could be undefined if the program was released
46
49
*/
47
50
/*@internal */
48
- getProgramOrUndefined ( ) : Program | undefined ;
51
+ getProgramOrUndefined ( ) : ts . Program | undefined ;
49
52
/**
50
53
* Releases reference to the program, making all the other operations that need program to fail.
51
54
*/
@@ -54,39 +57,39 @@ namespace ts {
54
57
/**
55
58
* Get compiler options of the program
56
59
*/
57
- getCompilerOptions ( ) : CompilerOptions ;
60
+ getCompilerOptions ( ) : ts . CompilerOptions ;
58
61
/**
59
62
* Get the source file in the program with file name
60
63
*/
61
- getSourceFile ( fileName : string ) : SourceFile | undefined ;
64
+ getSourceFile ( fileName : string ) : ts . SourceFile | undefined ;
62
65
/**
63
66
* Get a list of files in the program
64
67
*/
65
- getSourceFiles ( ) : readonly SourceFile [ ] ;
68
+ getSourceFiles ( ) : readonly ts . SourceFile [ ] ;
66
69
/**
67
70
* Get the diagnostics for compiler options
68
71
*/
69
- getOptionsDiagnostics ( cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
72
+ getOptionsDiagnostics ( cancellationToken ?: ts . CancellationToken ) : readonly ts . Diagnostic [ ] ;
70
73
/**
71
74
* Get the diagnostics that dont belong to any file
72
75
*/
73
- getGlobalDiagnostics ( cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
76
+ getGlobalDiagnostics ( cancellationToken ?: ts . CancellationToken ) : readonly ts . Diagnostic [ ] ;
74
77
/**
75
78
* Get the diagnostics from config file parsing
76
79
*/
77
- getConfigFileParsingDiagnostics ( ) : readonly Diagnostic [ ] ;
80
+ getConfigFileParsingDiagnostics ( ) : readonly ts . Diagnostic [ ] ;
78
81
/**
79
82
* Get the syntax diagnostics, for all source files if source file is not supplied
80
83
*/
81
- getSyntacticDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
84
+ getSyntacticDiagnostics ( sourceFile ?: ts . SourceFile , cancellationToken ?: ts . CancellationToken ) : readonly ts . Diagnostic [ ] ;
82
85
/**
83
86
* Get the declaration diagnostics, for all source files if source file is not supplied
84
87
*/
85
- getDeclarationDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : readonly DiagnosticWithLocation [ ] ;
88
+ getDeclarationDiagnostics ( sourceFile ?: ts . SourceFile , cancellationToken ?: ts . CancellationToken ) : readonly ts . DiagnosticWithLocation [ ] ;
86
89
/**
87
90
* Get all the dependencies of the file
88
91
*/
89
- getAllDependencies ( sourceFile : SourceFile ) : readonly string [ ] ;
92
+ getAllDependencies ( sourceFile : ts . SourceFile ) : readonly string [ ] ;
90
93
91
94
/**
92
95
* Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program
@@ -96,7 +99,7 @@ namespace ts {
96
99
* In case of SemanticDiagnosticsBuilderProgram if the source file is not provided,
97
100
* it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics
98
101
*/
99
- getSemanticDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] ;
102
+ getSemanticDiagnostics ( sourceFile ?: ts . SourceFile , cancellationToken ?: ts . CancellationToken ) : readonly ts . Diagnostic [ ] ;
100
103
/**
101
104
* Emits the JavaScript and declaration files.
102
105
* When targetSource file is specified, emits the files corresponding to that source file,
@@ -108,9 +111,9 @@ namespace ts {
108
111
* The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
109
112
* in that order would be used to write the files
110
113
*/
111
- emit ( targetSourceFile ?: SourceFile , writeFile ?: WriteFileCallback , cancellationToken ?: CancellationToken , emitOnlyDtsFiles ?: boolean , customTransformers ?: CustomTransformers ) : EmitResult ;
114
+ emit ( targetSourceFile ?: ts . SourceFile , writeFile ?: ts . WriteFileCallback , cancellationToken ?: ts . CancellationToken , emitOnlyDtsFiles ?: boolean , customTransformers ?: ts . CustomTransformers ) : ts . EmitResult ;
112
115
/*@internal */
113
- emitBuildInfo ( writeFile ?: WriteFileCallback , cancellationToken ?: CancellationToken ) : EmitResult ;
116
+ emitBuildInfo ( writeFile ?: ts . WriteFileCallback , cancellationToken ?: ts . CancellationToken ) : ts . EmitResult ;
114
117
/**
115
118
* Get the current directory of the program
116
119
*/
@@ -127,7 +130,7 @@ namespace ts {
127
130
* Gets the semantic diagnostics from the program for the next affected file and caches it
128
131
* Returns undefined if the iteration is complete
129
132
*/
130
- getSemanticDiagnosticsOfNextAffectedFile ( cancellationToken ?: CancellationToken , ignoreSourceFile ?: ( sourceFile : SourceFile ) => boolean ) : AffectedFileResult < readonly Diagnostic [ ] > ;
133
+ getSemanticDiagnosticsOfNextAffectedFile ( cancellationToken ?: ts . CancellationToken , ignoreSourceFile ?: ( sourceFile : ts . SourceFile ) => boolean ) : AffectedFileResult < readonly ts . Diagnostic [ ] > ;
131
134
}
132
135
133
136
/**
@@ -140,35 +143,35 @@ namespace ts {
140
143
* The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
141
144
* in that order would be used to write the files
142
145
*/
143
- emitNextAffectedFile ( writeFile ?: WriteFileCallback , cancellationToken ?: CancellationToken , emitOnlyDtsFiles ?: boolean , customTransformers ?: CustomTransformers ) : AffectedFileResult < EmitResult > ;
146
+ emitNextAffectedFile ( writeFile ?: ts . WriteFileCallback , cancellationToken ?: ts . CancellationToken , emitOnlyDtsFiles ?: boolean , customTransformers ?: ts . CustomTransformers ) : AffectedFileResult < ts . EmitResult > ;
144
147
}
145
148
146
149
/**
147
150
* Create the builder to manage semantic diagnostics and cache them
148
151
*/
149
- export function createSemanticDiagnosticsBuilderProgram ( newProgram : Program , host : BuilderProgramHost , oldProgram ?: SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : SemanticDiagnosticsBuilderProgram ;
150
- export function createSemanticDiagnosticsBuilderProgram ( rootNames : readonly string [ ] | undefined , options : CompilerOptions | undefined , host ?: CompilerHost , oldProgram ?: SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : SemanticDiagnosticsBuilderProgram ;
151
- export function createSemanticDiagnosticsBuilderProgram ( newProgramOrRootNames : Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | CompilerOptions | undefined , oldProgramOrHost ?: CompilerHost | SemanticDiagnosticsBuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly Diagnostic [ ] | SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) {
152
- return createBuilderProgram ( BuilderProgramKind . SemanticDiagnosticsBuilderProgram , getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ) ;
152
+ export function createSemanticDiagnosticsBuilderProgram ( newProgram : ts . Program , host : BuilderProgramHost , oldProgram ?: SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] ) : SemanticDiagnosticsBuilderProgram ;
153
+ export function createSemanticDiagnosticsBuilderProgram ( rootNames : readonly string [ ] | undefined , options : ts . CompilerOptions | undefined , host ?: ts . CompilerHost , oldProgram ?: SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] , projectReferences ?: readonly ts . ProjectReference [ ] ) : SemanticDiagnosticsBuilderProgram ;
154
+ export function createSemanticDiagnosticsBuilderProgram ( newProgramOrRootNames : ts . Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | ts . CompilerOptions | undefined , oldProgramOrHost ?: ts . CompilerHost | SemanticDiagnosticsBuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly ts . Diagnostic [ ] | SemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] , projectReferences ?: readonly ts . ProjectReference [ ] ) {
155
+ return ts . createBuilderProgram ( ts . BuilderProgramKind . SemanticDiagnosticsBuilderProgram , ts . getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ) ;
153
156
}
154
157
155
158
/**
156
159
* Create the builder that can handle the changes in program and iterate through changed files
157
160
* to emit the those files and manage semantic diagnostics cache as well
158
161
*/
159
- export function createEmitAndSemanticDiagnosticsBuilderProgram ( newProgram : Program , host : BuilderProgramHost , oldProgram ?: EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : EmitAndSemanticDiagnosticsBuilderProgram ;
160
- export function createEmitAndSemanticDiagnosticsBuilderProgram ( rootNames : readonly string [ ] | undefined , options : CompilerOptions | undefined , host ?: CompilerHost , oldProgram ?: EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : EmitAndSemanticDiagnosticsBuilderProgram ;
161
- export function createEmitAndSemanticDiagnosticsBuilderProgram ( newProgramOrRootNames : Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | CompilerOptions | undefined , oldProgramOrHost ?: CompilerHost | EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly Diagnostic [ ] | EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) {
162
- return createBuilderProgram ( BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ) ;
162
+ export function createEmitAndSemanticDiagnosticsBuilderProgram ( newProgram : ts . Program , host : BuilderProgramHost , oldProgram ?: EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] ) : EmitAndSemanticDiagnosticsBuilderProgram ;
163
+ export function createEmitAndSemanticDiagnosticsBuilderProgram ( rootNames : readonly string [ ] | undefined , options : ts . CompilerOptions | undefined , host ?: ts . CompilerHost , oldProgram ?: EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] , projectReferences ?: readonly ts . ProjectReference [ ] ) : EmitAndSemanticDiagnosticsBuilderProgram ;
164
+ export function createEmitAndSemanticDiagnosticsBuilderProgram ( newProgramOrRootNames : ts . Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | ts . CompilerOptions | undefined , oldProgramOrHost ?: ts . CompilerHost | EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly ts . Diagnostic [ ] | EmitAndSemanticDiagnosticsBuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] , projectReferences ?: readonly ts . ProjectReference [ ] ) {
165
+ return ts . createBuilderProgram ( ts . BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , ts . getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ) ;
163
166
}
164
167
165
168
/**
166
169
* Creates a builder thats just abstraction over program and can be used with watch
167
170
*/
168
- export function createAbstractBuilder ( newProgram : Program , host : BuilderProgramHost , oldProgram ?: BuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : BuilderProgram ;
169
- export function createAbstractBuilder ( rootNames : readonly string [ ] | undefined , options : CompilerOptions | undefined , host ?: CompilerHost , oldProgram ?: BuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : BuilderProgram ;
170
- export function createAbstractBuilder ( newProgramOrRootNames : Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | CompilerOptions | undefined , oldProgramOrHost ?: CompilerHost | BuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly Diagnostic [ ] | BuilderProgram , configFileParsingDiagnostics ?: readonly Diagnostic [ ] , projectReferences ?: readonly ProjectReference [ ] ) : BuilderProgram {
171
- const { newProgram, configFileParsingDiagnostics : newConfigFileParsingDiagnostics } = getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ;
172
- return createRedirectedBuilderProgram ( ( ) => ( { program : newProgram , compilerOptions : newProgram . getCompilerOptions ( ) } ) , newConfigFileParsingDiagnostics ) ;
171
+ export function createAbstractBuilder ( newProgram : ts . Program , host : BuilderProgramHost , oldProgram ?: BuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] ) : BuilderProgram ;
172
+ export function createAbstractBuilder ( rootNames : readonly string [ ] | undefined , options : ts . CompilerOptions | undefined , host ?: ts . CompilerHost , oldProgram ?: BuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] , projectReferences ?: readonly ts . ProjectReference [ ] ) : BuilderProgram ;
173
+ export function createAbstractBuilder ( newProgramOrRootNames : ts . Program | readonly string [ ] | undefined , hostOrOptions : BuilderProgramHost | ts . CompilerOptions | undefined , oldProgramOrHost ?: ts . CompilerHost | BuilderProgram , configFileParsingDiagnosticsOrOldProgram ?: readonly ts . Diagnostic [ ] | BuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] , projectReferences ?: readonly ts . ProjectReference [ ] ) : BuilderProgram {
174
+ const { newProgram, configFileParsingDiagnostics : newConfigFileParsingDiagnostics } = ts . getBuilderCreationParameters ( newProgramOrRootNames , hostOrOptions , oldProgramOrHost , configFileParsingDiagnosticsOrOldProgram , configFileParsingDiagnostics , projectReferences ) ;
175
+ return ts . createRedirectedBuilderProgram ( ( ) => ( { program : newProgram , compilerOptions : newProgram . getCompilerOptions ( ) } ) , newConfigFileParsingDiagnostics ) ;
173
176
}
174
177
}
0 commit comments