Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: enable noImplicitOverride TypeScript option #21127

Merged
merged 1 commit into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/angular/cli/commands/add-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import { Schema as AddCommandSchema } from './add';
const npa = require('npm-package-arg');

export class AddCommand extends SchematicCommand<AddCommandSchema> {
readonly allowPrivateSchematics = true;
override readonly allowPrivateSchematics = true;

async initialize(options: AddCommandSchema & Arguments) {
override async initialize(options: AddCommandSchema & Arguments) {
if (options.registry) {
return super.initialize({ ...options, packageRegistry: options.registry });
} else {
Expand Down Expand Up @@ -235,7 +235,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
return this.executeSchematic(collectionName, options['--']);
}

async reportAnalytics(
override async reportAnalytics(
paths: string[],
options: AddCommandSchema & Arguments,
dimensions: (boolean | number | string)[] = [],
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/commands/build-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Arguments } from '../models/interface';
import { Schema as BuildCommandSchema } from './build';

export class BuildCommand extends ArchitectCommand<BuildCommandSchema> {
public readonly target = 'build';
public override readonly target = 'build';

public async run(options: ArchitectCommandOptions & Arguments) {
public override async run(options: ArchitectCommandOptions & Arguments) {
return this.runArchitectTarget(options);
}
}
8 changes: 5 additions & 3 deletions packages/angular/cli/commands/deploy-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ Find more packages on npm https://www.npmjs.com/search?q=ng%20deploy
`;

export class DeployCommand extends ArchitectCommand<DeployCommandSchema> {
public readonly target = 'deploy';
public readonly missingTargetError = BuilderMissing;
public override readonly target = 'deploy';
public override readonly missingTargetError = BuilderMissing;

public async initialize(options: DeployCommandSchema & Arguments): Promise<number | void> {
public override async initialize(
options: DeployCommandSchema & Arguments,
): Promise<number | void> {
if (!options.help) {
return super.initialize(options);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/cli/commands/e2e-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Arguments } from '../models/interface';
import { Schema as E2eCommandSchema } from './e2e';

export class E2eCommand extends ArchitectCommand<E2eCommandSchema> {
public readonly target = 'e2e';
public readonly multiTarget = true;
public readonly missingTargetError = `
public override readonly target = 'e2e';
public override readonly multiTarget = true;
public override readonly missingTargetError = `
Cannot find "e2e" target for the specified project.

You should add a package that implements end-to-end testing capabilities.
Expand All @@ -26,7 +26,7 @@ For example:
More options will be added to the list as they become available.
`;

async initialize(options: E2eCommandSchema & Arguments) {
override async initialize(options: E2eCommandSchema & Arguments) {
if (!options.help) {
return super.initialize(options);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/commands/extract-i18n-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Arguments } from '../models/interface';
import { Schema as ExtractI18nCommandSchema } from './extract-i18n';

export class ExtractI18nCommand extends ArchitectCommand<ExtractI18nCommandSchema> {
public readonly target = 'extract-i18n';
public override readonly target = 'extract-i18n';

public async run(options: ExtractI18nCommandSchema & Arguments) {
public override async run(options: ExtractI18nCommandSchema & Arguments) {
const version = process.version.substr(1).split('.');
if (Number(version[0]) === 12 && Number(version[1]) === 0) {
this.logger.error(
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/cli/commands/generate-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GenerateCommand extends SchematicCommand<GenerateCommandSchema> {
// Allows us to resolve aliases before reporting analytics
longSchematicName: string | undefined;

async initialize(options: GenerateCommandSchema & Arguments) {
override async initialize(options: GenerateCommandSchema & Arguments) {
// Fill up the schematics property of the command description.
const [collectionName, schematicName] = await this.parseSchematicInfo(options);
this.collectionName = collectionName;
Expand Down Expand Up @@ -75,7 +75,7 @@ export class GenerateCommand extends SchematicCommand<GenerateCommandSchema> {
});
}

async reportAnalytics(
override async reportAnalytics(
paths: string[],
options: GenerateCommandSchema & Arguments,
): Promise<void> {
Expand Down Expand Up @@ -104,7 +104,7 @@ export class GenerateCommand extends SchematicCommand<GenerateCommandSchema> {
return [collectionName, schematicName];
}

public async printHelp() {
public override async printHelp() {
await super.printHelp();

this.logger.info('');
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/cli/commands/lint-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ For example:
`;

export class LintCommand extends ArchitectCommand<LintCommandSchema> {
readonly target = 'lint';
readonly multiTarget = true;
readonly missingTargetError = MissingBuilder;
override readonly target = 'lint';
override readonly multiTarget = true;
override readonly missingTargetError = MissingBuilder;

async initialize(options: LintCommandSchema & Arguments): Promise<number | void> {
override async initialize(options: LintCommandSchema & Arguments): Promise<number | void> {
if (!options.help) {
return super.initialize(options);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/cli/commands/new-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { VERSION } from '../models/version';
import { Schema as NewCommandSchema } from './new';

export class NewCommand extends SchematicCommand<NewCommandSchema> {
public readonly allowMissingWorkspace = true;
schematicName = 'ng-new';
public override readonly allowMissingWorkspace = true;
override schematicName = 'ng-new';

async initialize(options: NewCommandSchema & Arguments) {
override async initialize(options: NewCommandSchema & Arguments) {
this.collectionName = options.collection || (await this.getDefaultSchematicCollection());

return super.initialize(options);
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/commands/run-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Arguments } from '../models/interface';
import { Schema as RunCommandSchema } from './run';

export class RunCommand extends ArchitectCommand<RunCommandSchema> {
public async run(options: ArchitectCommandOptions & Arguments) {
public override async run(options: ArchitectCommandOptions & Arguments) {
if (options.target) {
return this.runArchitectTarget(options);
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/commands/serve-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { Arguments } from '../models/interface';
import { Schema as ServeCommandSchema } from './serve';

export class ServeCommand extends ArchitectCommand<ServeCommandSchema> {
public readonly target = 'serve';
public override readonly target = 'serve';

public validate() {
return true;
}

public async run(options: ArchitectCommandOptions & Arguments) {
public override async run(options: ArchitectCommandOptions & Arguments) {
return this.runArchitectTarget(options);
}
}
6 changes: 3 additions & 3 deletions packages/angular/cli/commands/test-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { Arguments } from '../models/interface';
import { Schema as TestCommandSchema } from './test';

export class TestCommand extends ArchitectCommand<TestCommandSchema> {
public readonly target = 'test';
public readonly multiTarget = true;
public override readonly target = 'test';
public override readonly multiTarget = true;

public async run(options: ArchitectCommandOptions & Arguments) {
public override async run(options: ArchitectCommandOptions & Arguments) {
return this.runArchitectTarget(options);
}
}
4 changes: 2 additions & 2 deletions packages/angular/cli/commands/update-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ const disableVersionCheck =
disableVersionCheckEnv.toLowerCase() !== 'false';

export class UpdateCommand extends Command<UpdateCommandSchema> {
public readonly allowMissingWorkspace = true;
public override readonly allowMissingWorkspace = true;
private workflow!: NodeWorkflow;
private packageManager = PackageManager.Npm;

async initialize(options: UpdateCommandSchema & Arguments) {
override async initialize(options: UpdateCommandSchema & Arguments) {
this.packageManager = await getPackageManager(this.context.root);
this.workflow = new NodeWorkflow(this.context.root, {
packageManager: this.packageManager,
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export abstract class ArchitectCommand<
protected _architect!: Architect;
protected _architectHost!: WorkspaceNodeModulesArchitectHost;
protected _registry!: json.schema.SchemaRegistry;
protected readonly useReportAnalytics = false;
protected override readonly useReportAnalytics = false;

// If this command supports running multiple targets.
protected multiTarget = false;

target: string | undefined;
missingTargetError: string | undefined;

public async initialize(options: T & Arguments): Promise<number | void> {
public override async initialize(options: T & Arguments): Promise<number | void> {
this._registry = new json.schema.CoreSchemaRegistry();
this._registry.addPostTransform(json.schema.transforms.addUndefinedDefaults);
this._registry.useXDeprecatedProvider((msg) => this.logger.warn(msg));
Expand Down
10 changes: 5 additions & 5 deletions packages/angular/cli/models/schematic-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export class UnknownCollectionError extends Error {
}

export abstract class SchematicCommand<
T extends BaseSchematicSchema & BaseCommandOptions
T extends BaseSchematicSchema & BaseCommandOptions,
> extends Command<T> {
protected readonly allowPrivateSchematics: boolean = false;
protected readonly useReportAnalytics = false;
protected override readonly useReportAnalytics = false;
protected _workflow!: NodeWorkflow;

protected defaultCollectionName = '@schematics/angular';
Expand All @@ -70,7 +70,7 @@ export abstract class SchematicCommand<
super(context, description, logger);
}

public async initialize(options: T & Arguments) {
public override async initialize(options: T & Arguments) {
await this.createWorkflow(options);

if (this.schematicName) {
Expand All @@ -94,7 +94,7 @@ export abstract class SchematicCommand<
}
}

public async printHelp() {
public override async printHelp() {
await super.printHelp();
this.logger.info('');

Expand Down Expand Up @@ -138,7 +138,7 @@ export abstract class SchematicCommand<
return 0;
}

async printHelpUsage() {
override async printHelpUsage() {
const subCommandOption = this.description.options.filter((x) => x.subcommands)[0];

if (!subCommandOption || !subCommandOption.subcommands) {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/models/schematic-engine-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function shouldWrapSchematic(schematicFile: string): boolean {
}

export class SchematicEngineHost extends NodeModulesEngineHost {
protected _resolveReferenceString(refString: string, parentPath: string) {
protected override _resolveReferenceString(refString: string, parentPath: string) {
const [path, name] = refString.split('#', 2);
// Mimic behavior of ExportStringRef class used in default behavior
const fullPath = path[0] === '.' ? resolve(parentPath ?? process.cwd(), path) : path;
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/utilities/json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '../models/interface';

export class CommandJsonPathException extends BaseException {
constructor(public readonly path: string, public readonly name: string) {
constructor(public readonly path: string, public override readonly name: string) {
super(`File ${path} was not found while constructing the subcommand ${name}.`);
}
}
Expand All @@ -36,7 +36,7 @@ function _getEnumFromValue<E, T extends E[keyof E]>(
}

if (Object.values(enumeration).includes(value)) {
return (value as unknown) as T;
return value as unknown as T;
}

return defaultValue;
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/architect/src/architect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
* A JobRegistry that resolves targets from the host.
*/
class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
get<A extends json.JsonObject, I extends BuilderInput, O extends BuilderOutput>(
override get<A extends json.JsonObject, I extends BuilderInput, O extends BuilderOutput>(
name: string,
): Observable<experimental.jobs.JobHandler<A, I, O> | null> {
const m = name.match(/^{([^:]+):([^:]+)(?::([^:]*))?}$/i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator {
throw new Error('compilation is undefined.');
}

constructor(readonly options: IndexHtmlWebpackPluginOptions) {
constructor(override readonly options: IndexHtmlWebpackPluginOptions) {
super(options);
}

Expand Down Expand Up @@ -101,13 +101,13 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator {
};
}

async readAsset(path: string): Promise<string> {
override async readAsset(path: string): Promise<string> {
const data = this.compilation.assets[basename(path)].source();

return typeof data === 'string' ? data : data.toString();
}

protected async readIndex(path: string): Promise<string> {
protected override async readIndex(path: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
this.compilation.inputFileSystem.readFile(
path,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/core/node/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { NodeJsSyncHost } from '../host';
*/
export class TempScopedNodeJsSyncHost extends virtualFs.ScopedHost<fs.Stats> {
protected _sync?: virtualFs.SyncDelegateHost<fs.Stats>;
protected _root: Path;
protected override _root: Path;

constructor() {
const root = normalize(path.join(os.tmpdir(), `devkit-host-${+Date.now()}-${process.pid}`));
Expand Down
12 changes: 6 additions & 6 deletions packages/angular_devkit/core/src/logger/level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import { LogLevel, Logger } from './logger';

export class LevelTransformLogger extends Logger {
constructor(
public readonly name: string,
public readonly parent: Logger | null = null,
public override readonly name: string,
public override readonly parent: Logger | null = null,
public readonly levelTransform: (level: LogLevel) => LogLevel,
) {
super(name, parent);
}

log(level: LogLevel, message: string, metadata: JsonObject = {}): void {
override log(level: LogLevel, message: string, metadata: JsonObject = {}): void {
return super.log(this.levelTransform(level), message, metadata);
}

createChild(name: string): Logger {
override createChild(name: string): Logger {
return new LevelTransformLogger(name, this, this.levelTransform);
}
}
Expand All @@ -37,8 +37,8 @@ export class LevelCapLogger extends LevelTransformLogger {
};

constructor(
public readonly name: string,
public readonly parent: Logger | null = null,
public override readonly name: string,
public override readonly parent: Logger | null = null,
public readonly levelCap: LogLevel,
) {
super(name, parent, (level: LogLevel) => {
Expand Down
16 changes: 8 additions & 8 deletions packages/angular_devkit/core/src/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,22 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
return this.log('fatal', message, metadata);
}

toString() {
override toString() {
return `<Logger(${this.name})>`;
}

lift<R>(operator: Operator<LogEntry, R>): Observable<R> {
override lift<R>(operator: Operator<LogEntry, R>): Observable<R> {
return this._observable.lift(operator);
}

subscribe(): Subscription;
subscribe(observer: PartialObserver<LogEntry>): Subscription;
subscribe(
override subscribe(): Subscription;
override subscribe(observer: PartialObserver<LogEntry>): Subscription;
override subscribe(
next?: (value: LogEntry) => void,
error?: (error: Error) => void,
complete?: () => void,
): Subscription;
subscribe(
override subscribe(
_observerOrNext?: PartialObserver<LogEntry> | ((value: LogEntry) => void),
_error?: (error: Error) => void,
_complete?: () => void,
Expand All @@ -158,10 +158,10 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
return this._observable.subscribe.apply(
this._observable,
// eslint-disable-next-line prefer-rest-params
(arguments as unknown) as Parameters<Observable<LogEntry>['subscribe']>,
arguments as unknown as Parameters<Observable<LogEntry>['subscribe']>,
);
}
forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {
override forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {
return this._observable.forEach(next, PromiseCtor);
}
}