|
1 | | -// Currently we do not want to expose API for build, we should work out the API, and then expose it just like we did for builder/watch |
2 | 1 | /*@internal*/ |
3 | 2 | namespace ts { |
4 | | - const minimumDate = new Date(-8640000000000000); |
5 | | - const maximumDate = new Date(8640000000000000); |
6 | | - |
7 | | - export interface BuildHost { |
8 | | - verbose(diag: DiagnosticMessage, ...args: string[]): void; |
9 | | - error(diag: DiagnosticMessage, ...args: string[]): void; |
10 | | - errorDiagnostic(diag: Diagnostic): void; |
11 | | - message(diag: DiagnosticMessage, ...args: string[]): void; |
12 | | - } |
13 | | - |
14 | | - export interface BuildOptions extends OptionsBase { |
15 | | - dry?: boolean; |
16 | | - force?: boolean; |
17 | | - verbose?: boolean; |
18 | | - |
19 | | - /*@internal*/ clean?: boolean; |
20 | | - /*@internal*/ watch?: boolean; |
21 | | - /*@internal*/ help?: boolean; |
22 | | - |
23 | | - preserveWatchOutput?: boolean; |
24 | | - listEmittedFiles?: boolean; |
25 | | - listFiles?: boolean; |
26 | | - pretty?: boolean; |
27 | | - incremental?: boolean; |
28 | | - |
29 | | - traceResolution?: boolean; |
30 | | - /* @internal */ diagnostics?: boolean; |
31 | | - /* @internal */ extendedDiagnostics?: boolean; |
32 | | - } |
33 | | - |
34 | | - enum BuildResultFlags { |
35 | | - None = 0, |
36 | | - |
37 | | - /** |
38 | | - * No errors of any kind occurred during build |
39 | | - */ |
40 | | - Success = 1 << 0, |
41 | | - /** |
42 | | - * None of the .d.ts files emitted by this build were |
43 | | - * different from the existing files on disk |
44 | | - */ |
45 | | - DeclarationOutputUnchanged = 1 << 1, |
46 | | - |
47 | | - ConfigFileErrors = 1 << 2, |
48 | | - SyntaxErrors = 1 << 3, |
49 | | - TypeErrors = 1 << 4, |
50 | | - DeclarationEmitErrors = 1 << 5, |
51 | | - EmitErrors = 1 << 6, |
52 | | - |
53 | | - AnyErrors = ConfigFileErrors | SyntaxErrors | TypeErrors | DeclarationEmitErrors | EmitErrors |
54 | | - } |
55 | | - |
56 | 3 | export enum UpToDateStatusType { |
57 | 4 | Unbuildable, |
58 | 5 | UpToDate, |
@@ -194,6 +141,63 @@ namespace ts { |
194 | 141 | } |
195 | 142 | } |
196 | 143 |
|
| 144 | + export function resolveConfigFileProjectName(project: string): ResolvedConfigFileName { |
| 145 | + if (fileExtensionIs(project, Extension.Json)) { |
| 146 | + return project as ResolvedConfigFileName; |
| 147 | + } |
| 148 | + |
| 149 | + return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName; |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +namespace ts { |
| 154 | + const minimumDate = new Date(-8640000000000000); |
| 155 | + const maximumDate = new Date(8640000000000000); |
| 156 | + |
| 157 | + export interface BuildOptions { |
| 158 | + dry?: boolean; |
| 159 | + force?: boolean; |
| 160 | + verbose?: boolean; |
| 161 | + |
| 162 | + /*@internal*/ clean?: boolean; |
| 163 | + /*@internal*/ watch?: boolean; |
| 164 | + /*@internal*/ help?: boolean; |
| 165 | + |
| 166 | + preserveWatchOutput?: boolean; |
| 167 | + listEmittedFiles?: boolean; |
| 168 | + listFiles?: boolean; |
| 169 | + pretty?: boolean; |
| 170 | + incremental?: boolean; |
| 171 | + |
| 172 | + traceResolution?: boolean; |
| 173 | + /* @internal */ diagnostics?: boolean; |
| 174 | + /* @internal */ extendedDiagnostics?: boolean; |
| 175 | + |
| 176 | + [option: string]: CompilerOptionsValue | undefined; |
| 177 | + } |
| 178 | + |
| 179 | + enum BuildResultFlags { |
| 180 | + None = 0, |
| 181 | + |
| 182 | + /** |
| 183 | + * No errors of any kind occurred during build |
| 184 | + */ |
| 185 | + Success = 1 << 0, |
| 186 | + /** |
| 187 | + * None of the .d.ts files emitted by this build were |
| 188 | + * different from the existing files on disk |
| 189 | + */ |
| 190 | + DeclarationOutputUnchanged = 1 << 1, |
| 191 | + |
| 192 | + ConfigFileErrors = 1 << 2, |
| 193 | + SyntaxErrors = 1 << 3, |
| 194 | + TypeErrors = 1 << 4, |
| 195 | + DeclarationEmitErrors = 1 << 5, |
| 196 | + EmitErrors = 1 << 6, |
| 197 | + |
| 198 | + AnyErrors = ConfigFileErrors | SyntaxErrors | TypeErrors | DeclarationEmitErrors | EmitErrors |
| 199 | + } |
| 200 | + |
197 | 201 | type ResolvedConfigFilePath = ResolvedConfigFileName & Path; |
198 | 202 | interface FileMap<T, U extends Path = Path> extends Map<T> { |
199 | 203 | get(key: U): T | undefined; |
@@ -231,6 +235,8 @@ namespace ts { |
231 | 235 | return fileExtensionIs(fileName, Extension.Dts); |
232 | 236 | } |
233 | 237 |
|
| 238 | + export type ReportEmitErrorSummary = (errorCount: number) => void; |
| 239 | + |
234 | 240 | export interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> { |
235 | 241 | getModifiedTime(fileName: string): Date | undefined; |
236 | 242 | setModifiedTime(fileName: string, date: Date): void; |
@@ -1527,15 +1533,7 @@ namespace ts { |
1527 | 1533 | } |
1528 | 1534 | } |
1529 | 1535 |
|
1530 | | - export function resolveConfigFileProjectName(project: string): ResolvedConfigFileName { |
1531 | | - if (fileExtensionIs(project, Extension.Json)) { |
1532 | | - return project as ResolvedConfigFileName; |
1533 | | - } |
1534 | | - |
1535 | | - return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName; |
1536 | | - } |
1537 | | - |
1538 | | - export function formatUpToDateStatus<T>(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) { |
| 1536 | + function formatUpToDateStatus<T>(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) { |
1539 | 1537 | switch (status.type) { |
1540 | 1538 | case UpToDateStatusType.OutOfDateWithSelf: |
1541 | 1539 | return formatMessage(Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, |
|
0 commit comments