Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Jun 6, 2019
1 parent 832928a commit 09eac67
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 78 deletions.
8 changes: 4 additions & 4 deletions src/compiler/transformers/classFields.ts
Expand Up @@ -158,7 +158,7 @@ namespace ts {

// Write any pending expressions from elided or moved computed property names
if (some(pendingExpressions)) {
statements.push(createExpressionStatement(inlineExpressions(pendingExpressions!)));
statements.push(createExpressionStatement(inlineExpressions(pendingExpressions!))); // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
}
pendingExpressions = savedPendingExpressions;

Expand Down Expand Up @@ -356,7 +356,7 @@ namespace ts {
* @param properties An array of property declarations to transform.
* @param receiver The receiver on which each property should be assigned.
*/
function addInitializedPropertyStatements(statements: Statement[], properties: ReadonlyArray<PropertyDeclaration>, receiver: LeftHandSideExpression) {
function addInitializedPropertyStatements(statements: Statement[], properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
for (const property of properties) {
const statement = createExpressionStatement(transformInitializedProperty(property, receiver));
setSourceMapRange(statement, moveRangePastModifiers(property));
Expand All @@ -372,7 +372,7 @@ namespace ts {
* @param properties An array of property declarations to transform.
* @param receiver The receiver on which each property should be assigned.
*/
function generateInitializedPropertyExpressions(properties: ReadonlyArray<PropertyDeclaration>, receiver: LeftHandSideExpression) {
function generateInitializedPropertyExpressions(properties: readonly PropertyDeclaration[], receiver: LeftHandSideExpression) {
const expressions: Expression[] = [];
for (const property of properties) {
const expression = transformInitializedProperty(property, receiver);
Expand All @@ -397,7 +397,7 @@ namespace ts {
const propertyName = isComputedPropertyName(property.name) && !isSimpleInlineableExpression(property.name.expression)
? updateComputedPropertyName(property.name, getGeneratedNameForNode(property.name))
: property.name;
const initializer = visitNode(property.initializer!, visitor, isExpression);
const initializer = visitNode(property.initializer, visitor, isExpression);
const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);

return createAssignment(memberAccess, initializer);
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/transformers/ts.ts
Expand Up @@ -921,8 +921,8 @@ namespace ts {
setOriginalNode(
setTextRange(
createConstructor(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*decorators*/ undefined,
/*modifiers*/ undefined,
parameters,
body
),
Expand Down Expand Up @@ -997,7 +997,7 @@ namespace ts {
* @param node The current class.
* @param constructor The current class constructor.
*/
function transformConstructorBody(members: NodeArray<ClassElement>, constructor: ConstructorDeclaration, propertyAssignments: ReadonlyArray<ParameterPropertyDeclaration>) {
function transformConstructorBody(members: NodeArray<ClassElement>, constructor: ConstructorDeclaration, propertyAssignments: readonly ParameterPropertyDeclaration[]) {
let statements: Statement[] = [];
let indexOfFirstStatement = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/utilities.ts
Expand Up @@ -303,7 +303,7 @@ namespace ts {
* @param node The class node.
* @param isStatic A value indicating whether to get properties from the static or instance side of the class.
*/
export function getInitializedProperties(node: ClassExpression | ClassDeclaration, isStatic: boolean): ReadonlyArray<PropertyDeclaration> {
export function getInitializedProperties(node: ClassExpression | ClassDeclaration, isStatic: boolean): readonly PropertyDeclaration[] {
return filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty);
}

Expand Down
45 changes: 23 additions & 22 deletions src/compiler/tsbuild.ts
Expand Up @@ -150,7 +150,7 @@ namespace ts {
}
}

namespace ts {
namespace ts { // eslint-disable-line no-redeclare
const minimumDate = new Date(-8640000000000000);
const maximumDate = new Date(8640000000000000);

Expand Down Expand Up @@ -280,7 +280,7 @@ namespace ts {
getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject<T> | undefined;

// Currently used for testing but can be made public if needed:
/*@internal*/ getBuildOrder(): ReadonlyArray<ResolvedConfigFileName>;
/*@internal*/ getBuildOrder(): readonly ResolvedConfigFileName[];

// Testing only
/*@internal*/ getUpToDateStatusOfProject(project: string): UpToDateStatus;
Expand Down Expand Up @@ -330,11 +330,11 @@ namespace ts {
return result;
}

export function createSolutionBuilder<T extends BuilderProgram>(host: SolutionBuilderHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T> {
export function createSolutionBuilder<T extends BuilderProgram>(host: SolutionBuilderHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T> {
return createSolutionBuilderWorker(/*watch*/ false, host, rootNames, defaultOptions);
}

export function createSolutionBuilderWithWatch<T extends BuilderProgram>(host: SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T> {
export function createSolutionBuilderWithWatch<T extends BuilderProgram>(host: SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T> {
return createSolutionBuilderWorker(/*watch*/ true, host, rootNames, defaultOptions);
}

Expand All @@ -360,7 +360,7 @@ namespace ts {
// State of solution
readonly options: BuildOptions;
readonly baseCompilerOptions: CompilerOptions;
readonly rootNames: ReadonlyArray<string>;
readonly rootNames: readonly string[];

readonly resolvedConfigFilePaths: Map<ResolvedConfigFilePath>;
readonly configFileCache: ConfigFileMap<ConfigFileCacheEntry>;
Expand Down Expand Up @@ -401,7 +401,7 @@ namespace ts {
writeLog: (s: string) => void;
}

function createSolutionBuilderState<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, options: BuildOptions): SolutionBuilderState<T> {
function createSolutionBuilderState<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], options: BuildOptions): SolutionBuilderState<T> {
const host = hostOrHostWithWatch as SolutionBuilderHost<T>;
const hostWithWatch = hostOrHostWithWatch as SolutionBuilderWithWatchHost<T>;
const currentDirectory = host.getCurrentDirectory();
Expand Down Expand Up @@ -704,14 +704,14 @@ namespace ts {
getBuilderProgram(): T | undefined;
getProgram(): Program | undefined;
getSourceFile(fileName: string): SourceFile | undefined;
getSourceFiles(): ReadonlyArray<SourceFile>;
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic>;
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getAllDependencies(sourceFile: SourceFile): ReadonlyArray<string>;
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<ReadonlyArray<Diagnostic>>;
getSourceFiles(): readonly SourceFile[];
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
getAllDependencies(sourceFile: SourceFile): readonly string[];
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult<readonly Diagnostic[]>;
/*
* Calling emit directly with targetSourceFile and emitOnlyDtsFiles set to true is not advised since
* emit in build system is responsible in updating status of the project
Expand Down Expand Up @@ -883,7 +883,7 @@ namespace ts {
return program && action(program);
}

function withProgramOrEmptyArray<U>(action: (program: T) => ReadonlyArray<U>): ReadonlyArray<U> {
function withProgramOrEmptyArray<U>(action: (program: T) => readonly U[]): readonly U[] {
return withProgramOrUndefined(action) || emptyArray;
}

Expand Down Expand Up @@ -924,7 +924,7 @@ namespace ts {
step++;
}

function handleDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, errorFlags: BuildResultFlags, errorType: string) {
function handleDiagnostics(diagnostics: readonly Diagnostic[], errorFlags: BuildResultFlags, errorType: string) {
if (diagnostics.length) {
buildResult = buildErrors(
state,
Expand Down Expand Up @@ -1319,7 +1319,7 @@ namespace ts {
state: SolutionBuilderState<T>,
resolvedPath: ResolvedConfigFilePath,
program: T | undefined,
diagnostics: ReadonlyArray<Diagnostic>,
diagnostics: readonly Diagnostic[],
errorFlags: BuildResultFlags,
errorType: string
) {
Expand Down Expand Up @@ -1933,9 +1933,9 @@ namespace ts {
* A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but
* can dynamically add/remove other projects based on changes on the rootNames' references
*/
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: false, host: SolutionBuilderHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T>;
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: true, host: SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, defaultOptions: BuildOptions): SolutionBuilder<T>;
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: ReadonlyArray<string>, options: BuildOptions): SolutionBuilder<T> {
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: false, host: SolutionBuilderHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T>;
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: true, host: SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder<T>;
function createSolutionBuilderWorker<T extends BuilderProgram>(watch: boolean, hostOrHostWithWatch: SolutionBuilderHost<T> | SolutionBuilderWithWatchHost<T>, rootNames: readonly string[], options: BuildOptions): SolutionBuilder<T> {
const state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options);
return {
build: (project, cancellationToken) => build(state, project, cancellationToken),
Expand Down Expand Up @@ -1971,11 +1971,11 @@ namespace ts {
}
}

function reportErrors({ host }: SolutionBuilderState, errors: ReadonlyArray<Diagnostic>) {
function reportErrors({ host }: SolutionBuilderState, errors: readonly Diagnostic[]) {
errors.forEach(err => host.reportDiagnostic(err));
}

function reportAndStoreErrors(state: SolutionBuilderState, proj: ResolvedConfigFilePath, errors: ReadonlyArray<Diagnostic>) {
function reportAndStoreErrors(state: SolutionBuilderState, proj: ResolvedConfigFilePath, errors: readonly Diagnostic[]) {
reportErrors(state, errors);
state.projectErrorsReported.set(proj, true);
if (errors.length) {
Expand Down Expand Up @@ -2098,6 +2098,7 @@ namespace ts {
);
case UpToDateStatusType.ContainerOnly:
// Don't report status on "solution" projects
// falls through
case UpToDateStatusType.ComputingUpstream:
// Should never leak from getUptoDateStatusWorker
break;
Expand Down
24 changes: 12 additions & 12 deletions src/compiler/watch.ts
Expand Up @@ -88,7 +88,7 @@ namespace ts {
return result;
}

export function getErrorCountForSummary(diagnostics: ReadonlyArray<Diagnostic>) {
export function getErrorCountForSummary(diagnostics: readonly Diagnostic[]) {
return countWhere(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
}

Expand All @@ -110,12 +110,12 @@ namespace ts {
export interface ProgramToEmitFilesAndReportErrors {
getCurrentDirectory(): string;
getCompilerOptions(): CompilerOptions;
getSourceFiles(): ReadonlyArray<SourceFile>;
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic>;
getSourceFiles(): readonly SourceFile[];
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult;
}

Expand Down Expand Up @@ -413,10 +413,10 @@ namespace ts {
}

export interface IncrementalCompilationOptions {
rootNames: ReadonlyArray<string>;
rootNames: readonly string[];
options: CompilerOptions;
configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>;
projectReferences?: ReadonlyArray<ProjectReference>;
configFileParsingDiagnostics?: readonly Diagnostic[];
projectReferences?: readonly ProjectReference[];
host?: CompilerHost;
reportDiagnostic?: DiagnosticReporter;
reportErrorSummary?: ReportEmitErrorSummary;
Expand All @@ -438,7 +438,7 @@ namespace ts {
}
}

namespace ts {
namespace ts { // eslint-disable-line no-redeclare
export function readBuilderProgram(compilerOptions: CompilerOptions, readFile: (path: string) => string | undefined) {
if (compilerOptions.out || compilerOptions.outFile) return undefined;
const buildInfoPath = getOutputPathForBuildInfo(compilerOptions);
Expand All @@ -460,7 +460,7 @@ namespace ts {
}

export interface IncrementalProgramOptions<T extends BuilderProgram> {
rootNames: ReadonlyArray<string>;
rootNames: readonly string[];
options: CompilerOptions;
configFileParsingDiagnostics?: readonly Diagnostic[];
projectReferences?: readonly ProjectReference[];
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsbuild/helpers.ts
Expand Up @@ -94,7 +94,7 @@ declare const console: { log(msg: any): void; };`;
}
}

function generateSourceMapBaselineFiles(fs: vfs.FileSystem, mapFileNames: ReadonlyArray<string>) {
function generateSourceMapBaselineFiles(fs: vfs.FileSystem, mapFileNames: readonly string[]) {
for (const mapFile of mapFileNames) {
if (!fs.existsSync(mapFile)) continue;
const text = Harness.SourceMapRecorder.getSourceMapRecordWithVFS(fs, mapFile);
Expand Down
16 changes: 8 additions & 8 deletions src/testRunner/unittests/tsbuildWatchMode.ts
Expand Up @@ -16,12 +16,12 @@ namespace ts.tscWatch {
return host;
}

export function createSolutionBuilder(system: WatchedSystem, rootNames: ReadonlyArray<string>, defaultOptions?: BuildOptions) {
export function createSolutionBuilder(system: WatchedSystem, rootNames: readonly string[], defaultOptions?: BuildOptions) {
const host = createSolutionBuilderHost(system);
return ts.createSolutionBuilder(host, rootNames, defaultOptions || {});
}

function createSolutionBuilderWithWatch(system: TsBuildWatchSystem, rootNames: ReadonlyArray<string>, defaultOptions?: BuildOptions) {
function createSolutionBuilderWithWatch(system: TsBuildWatchSystem, rootNames: readonly string[], defaultOptions?: BuildOptions) {
const host = createSolutionBuilderWithWatchHost(system);
const solutionBuilder = ts.createSolutionBuilderWithWatch(host, rootNames, defaultOptions || { watch: true });
solutionBuilder.build();
Expand Down Expand Up @@ -699,7 +699,7 @@ let x: string = 10;`);

function verifyScenario(
edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder<EmitAndSemanticDiagnosticsBuilderProgram>) => void,
expectedFilesAfterEdit: ReadonlyArray<string>
expectedFilesAfterEdit: readonly string[]
) {
it("with tsc-watch", () => {
const { host, solutionBuilder, watch } = createSolutionAndWatchMode();
Expand Down Expand Up @@ -922,11 +922,11 @@ export function gfoo() {

function verifyScenario(
edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder<EmitAndSemanticDiagnosticsBuilderProgram>) => void,
expectedEditErrors: ReadonlyArray<string>,
expectedProgramFiles: ReadonlyArray<string>,
expectedWatchedFiles: ReadonlyArray<string>,
expectedWatchedDirectoriesRecursive: ReadonlyArray<string>,
dependencies: ReadonlyArray<[string, ReadonlyArray<string>]>,
expectedEditErrors: readonly string[],
expectedProgramFiles: readonly string[],
expectedWatchedFiles: readonly string[],
expectedWatchedDirectoriesRecursive: readonly string[],
dependencies: readonly [string, readonly string[]][],
revert?: (host: TsBuildWatchSystem) => void,
orphanInfosAfterEdit?: readonly string[],
orphanInfosAfterRevert?: readonly string[]) {
Expand Down

0 comments on commit 09eac67

Please sign in to comment.