Skip to content

Commit 9afe185

Browse files
committed
build: enable noImplicitOverride TypeScript option
The `noImplicitOverride` TypeScript option improves code quality by ensuring that properties from base classes are not accidentally overriden. Reference: https://www.typescriptlang.org/tsconfig#noImplicitOverride
1 parent 8be19da commit 9afe185

33 files changed

+102
-99
lines changed

packages/angular/cli/commands/add-impl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import { Schema as AddCommandSchema } from './add';
3131
const npa = require('npm-package-arg');
3232

3333
export class AddCommand extends SchematicCommand<AddCommandSchema> {
34-
readonly allowPrivateSchematics = true;
34+
override readonly allowPrivateSchematics = true;
3535

36-
async initialize(options: AddCommandSchema & Arguments) {
36+
override async initialize(options: AddCommandSchema & Arguments) {
3737
if (options.registry) {
3838
return super.initialize({ ...options, packageRegistry: options.registry });
3939
} else {
@@ -235,7 +235,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
235235
return this.executeSchematic(collectionName, options['--']);
236236
}
237237

238-
async reportAnalytics(
238+
override async reportAnalytics(
239239
paths: string[],
240240
options: AddCommandSchema & Arguments,
241241
dimensions: (boolean | number | string)[] = [],

packages/angular/cli/commands/build-impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { Arguments } from '../models/interface';
1111
import { Schema as BuildCommandSchema } from './build';
1212

1313
export class BuildCommand extends ArchitectCommand<BuildCommandSchema> {
14-
public readonly target = 'build';
14+
public override readonly target = 'build';
1515

16-
public async run(options: ArchitectCommandOptions & Arguments) {
16+
public override async run(options: ArchitectCommandOptions & Arguments) {
1717
return this.runArchitectTarget(options);
1818
}
1919
}

packages/angular/cli/commands/deploy-impl.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ Find more packages on npm https://www.npmjs.com/search?q=ng%20deploy
2525
`;
2626

2727
export class DeployCommand extends ArchitectCommand<DeployCommandSchema> {
28-
public readonly target = 'deploy';
29-
public readonly missingTargetError = BuilderMissing;
28+
public override readonly target = 'deploy';
29+
public override readonly missingTargetError = BuilderMissing;
3030

31-
public async initialize(options: DeployCommandSchema & Arguments): Promise<number | void> {
31+
public override async initialize(
32+
options: DeployCommandSchema & Arguments,
33+
): Promise<number | void> {
3234
if (!options.help) {
3335
return super.initialize(options);
3436
}

packages/angular/cli/commands/e2e-impl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { Arguments } from '../models/interface';
1111
import { Schema as E2eCommandSchema } from './e2e';
1212

1313
export class E2eCommand extends ArchitectCommand<E2eCommandSchema> {
14-
public readonly target = 'e2e';
15-
public readonly multiTarget = true;
16-
public readonly missingTargetError = `
14+
public override readonly target = 'e2e';
15+
public override readonly multiTarget = true;
16+
public override readonly missingTargetError = `
1717
Cannot find "e2e" target for the specified project.
1818
1919
You should add a package that implements end-to-end testing capabilities.
@@ -26,7 +26,7 @@ For example:
2626
More options will be added to the list as they become available.
2727
`;
2828

29-
async initialize(options: E2eCommandSchema & Arguments) {
29+
override async initialize(options: E2eCommandSchema & Arguments) {
3030
if (!options.help) {
3131
return super.initialize(options);
3232
}

packages/angular/cli/commands/extract-i18n-impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { Arguments } from '../models/interface';
1111
import { Schema as ExtractI18nCommandSchema } from './extract-i18n';
1212

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

16-
public async run(options: ExtractI18nCommandSchema & Arguments) {
16+
public override async run(options: ExtractI18nCommandSchema & Arguments) {
1717
const version = process.version.substr(1).split('.');
1818
if (Number(version[0]) === 12 && Number(version[1]) === 0) {
1919
this.logger.error(

packages/angular/cli/commands/generate-impl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class GenerateCommand extends SchematicCommand<GenerateCommandSchema> {
1616
// Allows us to resolve aliases before reporting analytics
1717
longSchematicName: string | undefined;
1818

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

78-
async reportAnalytics(
78+
override async reportAnalytics(
7979
paths: string[],
8080
options: GenerateCommandSchema & Arguments,
8181
): Promise<void> {
@@ -104,7 +104,7 @@ export class GenerateCommand extends SchematicCommand<GenerateCommandSchema> {
104104
return [collectionName, schematicName];
105105
}
106106

107-
public async printHelp() {
107+
public override async printHelp() {
108108
await super.printHelp();
109109

110110
this.logger.info('');

packages/angular/cli/commands/lint-impl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ For example:
2020
`;
2121

2222
export class LintCommand extends ArchitectCommand<LintCommandSchema> {
23-
readonly target = 'lint';
24-
readonly multiTarget = true;
25-
readonly missingTargetError = MissingBuilder;
23+
override readonly target = 'lint';
24+
override readonly multiTarget = true;
25+
override readonly missingTargetError = MissingBuilder;
2626

27-
async initialize(options: LintCommandSchema & Arguments): Promise<number | void> {
27+
override async initialize(options: LintCommandSchema & Arguments): Promise<number | void> {
2828
if (!options.help) {
2929
return super.initialize(options);
3030
}

packages/angular/cli/commands/new-impl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { VERSION } from '../models/version';
1212
import { Schema as NewCommandSchema } from './new';
1313

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

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

2121
return super.initialize(options);

packages/angular/cli/commands/run-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Arguments } from '../models/interface';
1111
import { Schema as RunCommandSchema } from './run';
1212

1313
export class RunCommand extends ArchitectCommand<RunCommandSchema> {
14-
public async run(options: ArchitectCommandOptions & Arguments) {
14+
public override async run(options: ArchitectCommandOptions & Arguments) {
1515
if (options.target) {
1616
return this.runArchitectTarget(options);
1717
} else {

packages/angular/cli/commands/serve-impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { Arguments } from '../models/interface';
1111
import { Schema as ServeCommandSchema } from './serve';
1212

1313
export class ServeCommand extends ArchitectCommand<ServeCommandSchema> {
14-
public readonly target = 'serve';
14+
public override readonly target = 'serve';
1515

1616
public validate() {
1717
return true;
1818
}
1919

20-
public async run(options: ArchitectCommandOptions & Arguments) {
20+
public override async run(options: ArchitectCommandOptions & Arguments) {
2121
return this.runArchitectTarget(options);
2222
}
2323
}

packages/angular/cli/commands/test-impl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { Arguments } from '../models/interface';
1111
import { Schema as TestCommandSchema } from './test';
1212

1313
export class TestCommand extends ArchitectCommand<TestCommandSchema> {
14-
public readonly target = 'test';
15-
public readonly multiTarget = true;
14+
public override readonly target = 'test';
15+
public override readonly multiTarget = true;
1616

17-
public async run(options: ArchitectCommandOptions & Arguments) {
17+
public override async run(options: ArchitectCommandOptions & Arguments) {
1818
return this.runArchitectTarget(options);
1919
}
2020
}

packages/angular/cli/commands/update-impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ const disableVersionCheck =
6363
disableVersionCheckEnv.toLowerCase() !== 'false';
6464

6565
export class UpdateCommand extends Command<UpdateCommandSchema> {
66-
public readonly allowMissingWorkspace = true;
66+
public override readonly allowMissingWorkspace = true;
6767
private workflow!: NodeWorkflow;
6868
private packageManager = PackageManager.Npm;
6969

70-
async initialize(options: UpdateCommandSchema & Arguments) {
70+
override async initialize(options: UpdateCommandSchema & Arguments) {
7171
this.packageManager = await getPackageManager(this.context.root);
7272
this.workflow = new NodeWorkflow(this.context.root, {
7373
packageManager: this.packageManager,

packages/angular/cli/models/architect-command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ export abstract class ArchitectCommand<
2828
protected _architect!: Architect;
2929
protected _architectHost!: WorkspaceNodeModulesArchitectHost;
3030
protected _registry!: json.schema.SchemaRegistry;
31-
protected readonly useReportAnalytics = false;
31+
protected override readonly useReportAnalytics = false;
3232

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

3636
target: string | undefined;
3737
missingTargetError: string | undefined;
3838

39-
public async initialize(options: T & Arguments): Promise<number | void> {
39+
public override async initialize(options: T & Arguments): Promise<number | void> {
4040
this._registry = new json.schema.CoreSchemaRegistry();
4141
this._registry.addPostTransform(json.schema.transforms.addUndefinedDefaults);
4242
this._registry.useXDeprecatedProvider((msg) => this.logger.warn(msg));

packages/angular/cli/models/schematic-command.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ export class UnknownCollectionError extends Error {
5656
}
5757

5858
export abstract class SchematicCommand<
59-
T extends BaseSchematicSchema & BaseCommandOptions
59+
T extends BaseSchematicSchema & BaseCommandOptions,
6060
> extends Command<T> {
6161
protected readonly allowPrivateSchematics: boolean = false;
62-
protected readonly useReportAnalytics = false;
62+
protected override readonly useReportAnalytics = false;
6363
protected _workflow!: NodeWorkflow;
6464

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

73-
public async initialize(options: T & Arguments) {
73+
public override async initialize(options: T & Arguments) {
7474
await this.createWorkflow(options);
7575

7676
if (this.schematicName) {
@@ -94,7 +94,7 @@ export abstract class SchematicCommand<
9494
}
9595
}
9696

97-
public async printHelp() {
97+
public override async printHelp() {
9898
await super.printHelp();
9999
this.logger.info('');
100100

@@ -138,7 +138,7 @@ export abstract class SchematicCommand<
138138
return 0;
139139
}
140140

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

144144
if (!subCommandOption || !subCommandOption.subcommands) {

packages/angular/cli/models/schematic-engine-host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function shouldWrapSchematic(schematicFile: string): boolean {
5151
}
5252

5353
export class SchematicEngineHost extends NodeModulesEngineHost {
54-
protected _resolveReferenceString(refString: string, parentPath: string) {
54+
protected override _resolveReferenceString(refString: string, parentPath: string) {
5555
const [path, name] = refString.split('#', 2);
5656
// Mimic behavior of ExportStringRef class used in default behavior
5757
const fullPath = path[0] === '.' ? resolve(parentPath ?? process.cwd(), path) : path;

packages/angular/cli/utilities/json-schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from '../models/interface';
2222

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

3838
if (Object.values(enumeration).includes(value)) {
39-
return (value as unknown) as T;
39+
return value as unknown as T;
4040
}
4141

4242
return defaultValue;

packages/angular_devkit/architect/src/architect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
215215
* A JobRegistry that resolves targets from the host.
216216
*/
217217
class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
218-
get<A extends json.JsonObject, I extends BuilderInput, O extends BuilderOutput>(
218+
override get<A extends json.JsonObject, I extends BuilderInput, O extends BuilderOutput>(
219219
name: string,
220220
): Observable<experimental.jobs.JobHandler<A, I, O> | null> {
221221
const m = name.match(/^{([^:]+):([^:]+)(?::([^:]*))?}$/i);

packages/angular_devkit/build_angular/src/webpack/plugins/index-html-webpack-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator {
3434
throw new Error('compilation is undefined.');
3535
}
3636

37-
constructor(readonly options: IndexHtmlWebpackPluginOptions) {
37+
constructor(override readonly options: IndexHtmlWebpackPluginOptions) {
3838
super(options);
3939
}
4040

@@ -101,13 +101,13 @@ export class IndexHtmlWebpackPlugin extends IndexHtmlGenerator {
101101
};
102102
}
103103

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

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

110-
protected async readIndex(path: string): Promise<string> {
110+
protected override async readIndex(path: string): Promise<string> {
111111
return new Promise<string>((resolve, reject) => {
112112
this.compilation.inputFileSystem.readFile(
113113
path,

packages/angular_devkit/core/node/testing/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { NodeJsSyncHost } from '../host';
1717
*/
1818
export class TempScopedNodeJsSyncHost extends virtualFs.ScopedHost<fs.Stats> {
1919
protected _sync?: virtualFs.SyncDelegateHost<fs.Stats>;
20-
protected _root: Path;
20+
protected override _root: Path;
2121

2222
constructor() {
2323
const root = normalize(path.join(os.tmpdir(), `devkit-host-${+Date.now()}-${process.pid}`));

packages/angular_devkit/core/src/logger/level.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import { LogLevel, Logger } from './logger';
1111

1212
export class LevelTransformLogger extends Logger {
1313
constructor(
14-
public readonly name: string,
15-
public readonly parent: Logger | null = null,
14+
public override readonly name: string,
15+
public override readonly parent: Logger | null = null,
1616
public readonly levelTransform: (level: LogLevel) => LogLevel,
1717
) {
1818
super(name, parent);
1919
}
2020

21-
log(level: LogLevel, message: string, metadata: JsonObject = {}): void {
21+
override log(level: LogLevel, message: string, metadata: JsonObject = {}): void {
2222
return super.log(this.levelTransform(level), message, metadata);
2323
}
2424

25-
createChild(name: string): Logger {
25+
override createChild(name: string): Logger {
2626
return new LevelTransformLogger(name, this, this.levelTransform);
2727
}
2828
}
@@ -37,8 +37,8 @@ export class LevelCapLogger extends LevelTransformLogger {
3737
};
3838

3939
constructor(
40-
public readonly name: string,
41-
public readonly parent: Logger | null = null,
40+
public override readonly name: string,
41+
public override readonly parent: Logger | null = null,
4242
public readonly levelCap: LogLevel,
4343
) {
4444
super(name, parent, (level: LogLevel) => {

packages/angular_devkit/core/src/logger/logger.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,22 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
134134
return this.log('fatal', message, metadata);
135135
}
136136

137-
toString() {
137+
override toString() {
138138
return `<Logger(${this.name})>`;
139139
}
140140

141-
lift<R>(operator: Operator<LogEntry, R>): Observable<R> {
141+
override lift<R>(operator: Operator<LogEntry, R>): Observable<R> {
142142
return this._observable.lift(operator);
143143
}
144144

145-
subscribe(): Subscription;
146-
subscribe(observer: PartialObserver<LogEntry>): Subscription;
147-
subscribe(
145+
override subscribe(): Subscription;
146+
override subscribe(observer: PartialObserver<LogEntry>): Subscription;
147+
override subscribe(
148148
next?: (value: LogEntry) => void,
149149
error?: (error: Error) => void,
150150
complete?: () => void,
151151
): Subscription;
152-
subscribe(
152+
override subscribe(
153153
_observerOrNext?: PartialObserver<LogEntry> | ((value: LogEntry) => void),
154154
_error?: (error: Error) => void,
155155
_complete?: () => void,
@@ -158,10 +158,10 @@ export class Logger extends Observable<LogEntry> implements LoggerApi {
158158
return this._observable.subscribe.apply(
159159
this._observable,
160160
// eslint-disable-next-line prefer-rest-params
161-
(arguments as unknown) as Parameters<Observable<LogEntry>['subscribe']>,
161+
arguments as unknown as Parameters<Observable<LogEntry>['subscribe']>,
162162
);
163163
}
164-
forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {
164+
override forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {
165165
return this._observable.forEach(next, PromiseCtor);
166166
}
167167
}

0 commit comments

Comments
 (0)