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