Skip to content

Commit d4f7962

Browse files
committed
CONVERSION STEP - inlineImports
1 parent 8885adb commit d4f7962

File tree

453 files changed

+71326
-66166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

453 files changed

+71326
-66166
lines changed

Diff for: src/compiler/binder.ts

+1,237-1,169
Large diffs are not rendered by default.

Diff for: src/compiler/builder.ts

+324-304
Large diffs are not rendered by default.

Diff for: src/compiler/builderPublic.ts

+36-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import * as ts from "./ts";
1+
import { BuilderProgramKind, createBuilderProgram, createRedirectedBuilderProgram, getBuilderCreationParameters,
2+
ReusableBuilderProgramState } from "./builder";
3+
import { CancellationToken, CompilerHost, CompilerOptions, CustomTransformers, Diagnostic, DiagnosticWithLocation,
4+
EmitResult, Program, ProjectReference, SourceFile, WriteFileCallback } from "./types";
25

3-
export type AffectedFileResult<T> = { result: T; affected: ts.SourceFile | ts.Program; } | undefined;
6+
export type AffectedFileResult<T> = { result: T; affected: SourceFile | Program; } | undefined;
47

58
export interface BuilderProgramHost {
69
/**
@@ -15,7 +18,7 @@ export interface BuilderProgramHost {
1518
* When emit or emitNextAffectedFile are called without writeFile,
1619
* this callback if present would be used to write files
1720
*/
18-
writeFile?: ts.WriteFileCallback;
21+
writeFile?: WriteFileCallback;
1922
/**
2023
* disable using source file version as signature for testing
2124
*/
@@ -33,20 +36,20 @@ export interface BuilderProgramHost {
3336
*/
3437
export interface BuilderProgram {
3538
/*@internal*/
36-
getState(): ts.ReusableBuilderProgramState;
39+
getState(): ReusableBuilderProgramState;
3740
/*@internal*/
3841
backupState(): void;
3942
/*@internal*/
4043
restoreState(): void;
4144
/**
4245
* Returns current program
4346
*/
44-
getProgram(): ts.Program;
47+
getProgram(): Program;
4548
/**
4649
* Returns current program that could be undefined if the program was released
4750
*/
4851
/*@internal*/
49-
getProgramOrUndefined(): ts.Program | undefined;
52+
getProgramOrUndefined(): Program | undefined;
5053
/**
5154
* Releases reference to the program, making all the other operations that need program to fail.
5255
*/
@@ -55,39 +58,39 @@ export interface BuilderProgram {
5558
/**
5659
* Get compiler options of the program
5760
*/
58-
getCompilerOptions(): ts.CompilerOptions;
61+
getCompilerOptions(): CompilerOptions;
5962
/**
6063
* Get the source file in the program with file name
6164
*/
62-
getSourceFile(fileName: string): ts.SourceFile | undefined;
65+
getSourceFile(fileName: string): SourceFile | undefined;
6366
/**
6467
* Get a list of files in the program
6568
*/
66-
getSourceFiles(): readonly ts.SourceFile[];
69+
getSourceFiles(): readonly SourceFile[];
6770
/**
6871
* Get the diagnostics for compiler options
6972
*/
70-
getOptionsDiagnostics(cancellationToken?: ts.CancellationToken): readonly ts.Diagnostic[];
73+
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
7174
/**
7275
* Get the diagnostics that dont belong to any file
7376
*/
74-
getGlobalDiagnostics(cancellationToken?: ts.CancellationToken): readonly ts.Diagnostic[];
77+
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
7578
/**
7679
* Get the diagnostics from config file parsing
7780
*/
78-
getConfigFileParsingDiagnostics(): readonly ts.Diagnostic[];
81+
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
7982
/**
8083
* Get the syntax diagnostics, for all source files if source file is not supplied
8184
*/
82-
getSyntacticDiagnostics(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken): readonly ts.Diagnostic[];
85+
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
8386
/**
8487
* Get the declaration diagnostics, for all source files if source file is not supplied
8588
*/
86-
getDeclarationDiagnostics(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken): readonly ts.DiagnosticWithLocation[];
89+
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
8790
/**
8891
* Get all the dependencies of the file
8992
*/
90-
getAllDependencies(sourceFile: ts.SourceFile): readonly string[];
93+
getAllDependencies(sourceFile: SourceFile): readonly string[];
9194

9295
/**
9396
* Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program
@@ -97,7 +100,7 @@ export interface BuilderProgram {
97100
* In case of SemanticDiagnosticsBuilderProgram if the source file is not provided,
98101
* it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics
99102
*/
100-
getSemanticDiagnostics(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken): readonly ts.Diagnostic[];
103+
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
101104
/**
102105
* Emits the JavaScript and declaration files.
103106
* When targetSource file is specified, emits the files corresponding to that source file,
@@ -109,9 +112,9 @@ export interface BuilderProgram {
109112
* The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
110113
* in that order would be used to write the files
111114
*/
112-
emit(targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: ts.CustomTransformers): ts.EmitResult;
115+
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
113116
/*@internal*/
114-
emitBuildInfo(writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken): ts.EmitResult;
117+
emitBuildInfo(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
115118
/**
116119
* Get the current directory of the program
117120
*/
@@ -128,7 +131,7 @@ export interface SemanticDiagnosticsBuilderProgram extends BuilderProgram {
128131
* Gets the semantic diagnostics from the program for the next affected file and caches it
129132
* Returns undefined if the iteration is complete
130133
*/
131-
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: ts.CancellationToken, ignoreSourceFile?: (sourceFile: ts.SourceFile) => boolean): AffectedFileResult<readonly ts.Diagnostic[]>;
134+
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<readonly Diagnostic[]>;
132135
}
133136

134137
/**
@@ -141,34 +144,34 @@ export interface EmitAndSemanticDiagnosticsBuilderProgram extends SemanticDiagno
141144
* The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
142145
* in that order would be used to write the files
143146
*/
144-
emitNextAffectedFile(writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: ts.CustomTransformers): AffectedFileResult<ts.EmitResult>;
147+
emitNextAffectedFile(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): AffectedFileResult<EmitResult>;
145148
}
146149

147150
/**
148151
* Create the builder to manage semantic diagnostics and cache them
149152
*/
150-
export function createSemanticDiagnosticsBuilderProgram(newProgram: ts.Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly ts.Diagnostic[]): SemanticDiagnosticsBuilderProgram;
151-
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;
152-
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[]) {
153-
return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
153+
export function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram;
154+
export function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram;
155+
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[]) {
156+
return createBuilderProgram(BuilderProgramKind.SemanticDiagnosticsBuilderProgram, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
154157
}
155158

156159
/**
157160
* Create the builder that can handle the changes in program and iterate through changed files
158161
* to emit the those files and manage semantic diagnostics cache as well
159162
*/
160-
export function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: ts.Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly ts.Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram;
161-
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;
162-
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[]) {
163-
return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
163+
export function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram;
164+
export function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram;
165+
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[]) {
166+
return createBuilderProgram(BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
164167
}
165168

166169
/**
167170
* Creates a builder thats just abstraction over program and can be used with watch
168171
*/
169-
export function createAbstractBuilder(newProgram: ts.Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly ts.Diagnostic[]): BuilderProgram;
170-
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;
171-
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 {
172-
const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences);
173-
return ts.createRedirectedBuilderProgram(() => ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }), newConfigFileParsingDiagnostics);
172+
export function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram;
173+
export function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram;
174+
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 {
175+
const { newProgram, configFileParsingDiagnostics: newConfigFileParsingDiagnostics } = getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences);
176+
return createRedirectedBuilderProgram(() => ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }), newConfigFileParsingDiagnostics);
174177
}

0 commit comments

Comments
 (0)