Make SolutionBuilder as Public API
This commit is contained in:
parent
3da47963d5
commit
5c18513e96
|
@ -1022,8 +1022,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @internal */
|
interface OptionsBase {
|
||||||
export interface OptionsBase {
|
|
||||||
[option: string]: CompilerOptionsValue | undefined;
|
[option: string]: CompilerOptionsValue | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,58 +1,5 @@
|
||||||
// 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
|
|
||||||
/*@internal*/
|
/*@internal*/
|
||||||
namespace ts {
|
namespace ts {
|
||||||
const minimumDate = new Date(-8640000000000000);
|
|
||||||
const maximumDate = new Date(8640000000000000);
|
|
||||||
|
|
||||||
export interface BuildHost {
|
|
||||||
verbose(diag: DiagnosticMessage, ...args: string[]): void;
|
|
||||||
error(diag: DiagnosticMessage, ...args: string[]): void;
|
|
||||||
errorDiagnostic(diag: Diagnostic): void;
|
|
||||||
message(diag: DiagnosticMessage, ...args: string[]): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BuildOptions extends OptionsBase {
|
|
||||||
dry?: boolean;
|
|
||||||
force?: boolean;
|
|
||||||
verbose?: boolean;
|
|
||||||
|
|
||||||
/*@internal*/ clean?: boolean;
|
|
||||||
/*@internal*/ watch?: boolean;
|
|
||||||
/*@internal*/ help?: boolean;
|
|
||||||
|
|
||||||
preserveWatchOutput?: boolean;
|
|
||||||
listEmittedFiles?: boolean;
|
|
||||||
listFiles?: boolean;
|
|
||||||
pretty?: boolean;
|
|
||||||
incremental?: boolean;
|
|
||||||
|
|
||||||
traceResolution?: boolean;
|
|
||||||
/* @internal */ diagnostics?: boolean;
|
|
||||||
/* @internal */ extendedDiagnostics?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum BuildResultFlags {
|
|
||||||
None = 0,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No errors of any kind occurred during build
|
|
||||||
*/
|
|
||||||
Success = 1 << 0,
|
|
||||||
/**
|
|
||||||
* None of the .d.ts files emitted by this build were
|
|
||||||
* different from the existing files on disk
|
|
||||||
*/
|
|
||||||
DeclarationOutputUnchanged = 1 << 1,
|
|
||||||
|
|
||||||
ConfigFileErrors = 1 << 2,
|
|
||||||
SyntaxErrors = 1 << 3,
|
|
||||||
TypeErrors = 1 << 4,
|
|
||||||
DeclarationEmitErrors = 1 << 5,
|
|
||||||
EmitErrors = 1 << 6,
|
|
||||||
|
|
||||||
AnyErrors = ConfigFileErrors | SyntaxErrors | TypeErrors | DeclarationEmitErrors | EmitErrors
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum UpToDateStatusType {
|
export enum UpToDateStatusType {
|
||||||
Unbuildable,
|
Unbuildable,
|
||||||
UpToDate,
|
UpToDate,
|
||||||
|
@ -194,6 +141,63 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveConfigFileProjectName(project: string): ResolvedConfigFileName {
|
||||||
|
if (fileExtensionIs(project, Extension.Json)) {
|
||||||
|
return project as ResolvedConfigFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ts {
|
||||||
|
const minimumDate = new Date(-8640000000000000);
|
||||||
|
const maximumDate = new Date(8640000000000000);
|
||||||
|
|
||||||
|
export interface BuildOptions {
|
||||||
|
dry?: boolean;
|
||||||
|
force?: boolean;
|
||||||
|
verbose?: boolean;
|
||||||
|
|
||||||
|
/*@internal*/ clean?: boolean;
|
||||||
|
/*@internal*/ watch?: boolean;
|
||||||
|
/*@internal*/ help?: boolean;
|
||||||
|
|
||||||
|
preserveWatchOutput?: boolean;
|
||||||
|
listEmittedFiles?: boolean;
|
||||||
|
listFiles?: boolean;
|
||||||
|
pretty?: boolean;
|
||||||
|
incremental?: boolean;
|
||||||
|
|
||||||
|
traceResolution?: boolean;
|
||||||
|
/* @internal */ diagnostics?: boolean;
|
||||||
|
/* @internal */ extendedDiagnostics?: boolean;
|
||||||
|
|
||||||
|
[option: string]: CompilerOptionsValue | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum BuildResultFlags {
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No errors of any kind occurred during build
|
||||||
|
*/
|
||||||
|
Success = 1 << 0,
|
||||||
|
/**
|
||||||
|
* None of the .d.ts files emitted by this build were
|
||||||
|
* different from the existing files on disk
|
||||||
|
*/
|
||||||
|
DeclarationOutputUnchanged = 1 << 1,
|
||||||
|
|
||||||
|
ConfigFileErrors = 1 << 2,
|
||||||
|
SyntaxErrors = 1 << 3,
|
||||||
|
TypeErrors = 1 << 4,
|
||||||
|
DeclarationEmitErrors = 1 << 5,
|
||||||
|
EmitErrors = 1 << 6,
|
||||||
|
|
||||||
|
AnyErrors = ConfigFileErrors | SyntaxErrors | TypeErrors | DeclarationEmitErrors | EmitErrors
|
||||||
|
}
|
||||||
|
|
||||||
type ResolvedConfigFilePath = ResolvedConfigFileName & Path;
|
type ResolvedConfigFilePath = ResolvedConfigFileName & Path;
|
||||||
interface FileMap<T, U extends Path = Path> extends Map<T> {
|
interface FileMap<T, U extends Path = Path> extends Map<T> {
|
||||||
get(key: U): T | undefined;
|
get(key: U): T | undefined;
|
||||||
|
@ -231,6 +235,8 @@ namespace ts {
|
||||||
return fileExtensionIs(fileName, Extension.Dts);
|
return fileExtensionIs(fileName, Extension.Dts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ReportEmitErrorSummary = (errorCount: number) => void;
|
||||||
|
|
||||||
export interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> {
|
export interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> {
|
||||||
getModifiedTime(fileName: string): Date | undefined;
|
getModifiedTime(fileName: string): Date | undefined;
|
||||||
setModifiedTime(fileName: string, date: Date): void;
|
setModifiedTime(fileName: string, date: Date): void;
|
||||||
|
@ -1527,15 +1533,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveConfigFileProjectName(project: string): ResolvedConfigFileName {
|
function formatUpToDateStatus<T>(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) {
|
||||||
if (fileExtensionIs(project, Extension.Json)) {
|
|
||||||
return project as ResolvedConfigFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatUpToDateStatus<T>(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) {
|
|
||||||
switch (status.type) {
|
switch (status.type) {
|
||||||
case UpToDateStatusType.OutOfDateWithSelf:
|
case UpToDateStatusType.OutOfDateWithSelf:
|
||||||
return formatMessage(Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2,
|
return formatMessage(Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2,
|
||||||
|
|
|
@ -88,8 +88,6 @@ namespace ts {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ReportEmitErrorSummary = (errorCount: number) => void;
|
|
||||||
|
|
||||||
export function getErrorCountForSummary(diagnostics: ReadonlyArray<Diagnostic>) {
|
export function getErrorCountForSummary(diagnostics: ReadonlyArray<Diagnostic>) {
|
||||||
return countWhere(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
return countWhere(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1905,7 +1905,8 @@ declare namespace ts {
|
||||||
enum ExitStatus {
|
enum ExitStatus {
|
||||||
Success = 0,
|
Success = 0,
|
||||||
DiagnosticsPresent_OutputsSkipped = 1,
|
DiagnosticsPresent_OutputsSkipped = 1,
|
||||||
DiagnosticsPresent_OutputsGenerated = 2
|
DiagnosticsPresent_OutputsGenerated = 2,
|
||||||
|
InvalidProject_OutputsSkipped = 3
|
||||||
}
|
}
|
||||||
interface EmitResult {
|
interface EmitResult {
|
||||||
emitSkipped: boolean;
|
emitSkipped: boolean;
|
||||||
|
@ -4555,6 +4556,46 @@ declare namespace ts {
|
||||||
*/
|
*/
|
||||||
function createWatchProgram<T extends BuilderProgram>(host: WatchCompilerHostOfConfigFile<T>): WatchOfConfigFile<T>;
|
function createWatchProgram<T extends BuilderProgram>(host: WatchCompilerHostOfConfigFile<T>): WatchOfConfigFile<T>;
|
||||||
}
|
}
|
||||||
|
declare namespace ts {
|
||||||
|
interface BuildOptions {
|
||||||
|
dry?: boolean;
|
||||||
|
force?: boolean;
|
||||||
|
verbose?: boolean;
|
||||||
|
preserveWatchOutput?: boolean;
|
||||||
|
listEmittedFiles?: boolean;
|
||||||
|
listFiles?: boolean;
|
||||||
|
pretty?: boolean;
|
||||||
|
incremental?: boolean;
|
||||||
|
traceResolution?: boolean;
|
||||||
|
[option: string]: CompilerOptionsValue | undefined;
|
||||||
|
}
|
||||||
|
type ReportEmitErrorSummary = (errorCount: number) => void;
|
||||||
|
interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> {
|
||||||
|
getModifiedTime(fileName: string): Date | undefined;
|
||||||
|
setModifiedTime(fileName: string, date: Date): void;
|
||||||
|
deleteFile(fileName: string): void;
|
||||||
|
reportDiagnostic: DiagnosticReporter;
|
||||||
|
reportSolutionBuilderStatus: DiagnosticReporter;
|
||||||
|
afterProgramEmitAndDiagnostics?(program: T): void;
|
||||||
|
}
|
||||||
|
interface SolutionBuilderHost<T extends BuilderProgram> extends SolutionBuilderHostBase<T> {
|
||||||
|
reportErrorSummary?: ReportEmitErrorSummary;
|
||||||
|
}
|
||||||
|
interface SolutionBuilderWithWatchHost<T extends BuilderProgram> extends SolutionBuilderHostBase<T>, WatchHost {
|
||||||
|
}
|
||||||
|
interface SolutionBuilder {
|
||||||
|
build(project?: string, cancellationToken?: CancellationToken): ExitStatus;
|
||||||
|
clean(project?: string): ExitStatus;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Create a function that reports watch status by writing to the system and handles the formating of the diagnostic
|
||||||
|
*/
|
||||||
|
function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter;
|
||||||
|
function createSolutionBuilderHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system?: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost<T>;
|
||||||
|
function createSolutionBuilderWithWatchHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system?: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost<T>;
|
||||||
|
function createSolutionBuilder<T extends BuilderProgram>(host: SolutionBuilderHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder;
|
||||||
|
function createSolutionBuilderWithWatch<T extends BuilderProgram>(host: SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder;
|
||||||
|
}
|
||||||
declare namespace ts.server {
|
declare namespace ts.server {
|
||||||
type ActionSet = "action::set";
|
type ActionSet = "action::set";
|
||||||
type ActionInvalidate = "action::invalidate";
|
type ActionInvalidate = "action::invalidate";
|
||||||
|
|
43
tests/baselines/reference/api/typescript.d.ts
vendored
43
tests/baselines/reference/api/typescript.d.ts
vendored
|
@ -1905,7 +1905,8 @@ declare namespace ts {
|
||||||
enum ExitStatus {
|
enum ExitStatus {
|
||||||
Success = 0,
|
Success = 0,
|
||||||
DiagnosticsPresent_OutputsSkipped = 1,
|
DiagnosticsPresent_OutputsSkipped = 1,
|
||||||
DiagnosticsPresent_OutputsGenerated = 2
|
DiagnosticsPresent_OutputsGenerated = 2,
|
||||||
|
InvalidProject_OutputsSkipped = 3
|
||||||
}
|
}
|
||||||
interface EmitResult {
|
interface EmitResult {
|
||||||
emitSkipped: boolean;
|
emitSkipped: boolean;
|
||||||
|
@ -4555,6 +4556,46 @@ declare namespace ts {
|
||||||
*/
|
*/
|
||||||
function createWatchProgram<T extends BuilderProgram>(host: WatchCompilerHostOfConfigFile<T>): WatchOfConfigFile<T>;
|
function createWatchProgram<T extends BuilderProgram>(host: WatchCompilerHostOfConfigFile<T>): WatchOfConfigFile<T>;
|
||||||
}
|
}
|
||||||
|
declare namespace ts {
|
||||||
|
interface BuildOptions {
|
||||||
|
dry?: boolean;
|
||||||
|
force?: boolean;
|
||||||
|
verbose?: boolean;
|
||||||
|
preserveWatchOutput?: boolean;
|
||||||
|
listEmittedFiles?: boolean;
|
||||||
|
listFiles?: boolean;
|
||||||
|
pretty?: boolean;
|
||||||
|
incremental?: boolean;
|
||||||
|
traceResolution?: boolean;
|
||||||
|
[option: string]: CompilerOptionsValue | undefined;
|
||||||
|
}
|
||||||
|
type ReportEmitErrorSummary = (errorCount: number) => void;
|
||||||
|
interface SolutionBuilderHostBase<T extends BuilderProgram> extends ProgramHost<T> {
|
||||||
|
getModifiedTime(fileName: string): Date | undefined;
|
||||||
|
setModifiedTime(fileName: string, date: Date): void;
|
||||||
|
deleteFile(fileName: string): void;
|
||||||
|
reportDiagnostic: DiagnosticReporter;
|
||||||
|
reportSolutionBuilderStatus: DiagnosticReporter;
|
||||||
|
afterProgramEmitAndDiagnostics?(program: T): void;
|
||||||
|
}
|
||||||
|
interface SolutionBuilderHost<T extends BuilderProgram> extends SolutionBuilderHostBase<T> {
|
||||||
|
reportErrorSummary?: ReportEmitErrorSummary;
|
||||||
|
}
|
||||||
|
interface SolutionBuilderWithWatchHost<T extends BuilderProgram> extends SolutionBuilderHostBase<T>, WatchHost {
|
||||||
|
}
|
||||||
|
interface SolutionBuilder {
|
||||||
|
build(project?: string, cancellationToken?: CancellationToken): ExitStatus;
|
||||||
|
clean(project?: string): ExitStatus;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Create a function that reports watch status by writing to the system and handles the formating of the diagnostic
|
||||||
|
*/
|
||||||
|
function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter;
|
||||||
|
function createSolutionBuilderHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system?: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost<T>;
|
||||||
|
function createSolutionBuilderWithWatchHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system?: System, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost<T>;
|
||||||
|
function createSolutionBuilder<T extends BuilderProgram>(host: SolutionBuilderHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder;
|
||||||
|
function createSolutionBuilderWithWatch<T extends BuilderProgram>(host: SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder;
|
||||||
|
}
|
||||||
declare namespace ts.server {
|
declare namespace ts.server {
|
||||||
type ActionSet = "action::set";
|
type ActionSet = "action::set";
|
||||||
type ActionInvalidate = "action::invalidate";
|
type ActionInvalidate = "action::invalidate";
|
||||||
|
|
Loading…
Reference in a new issue