Skip to content

Commit

Permalink
refactor: add override keyword to members implementing abstract decla…
Browse files Browse the repository at this point in the history
…rations (#42512)

In combination with the TS `noImplicitOverride` compatibility changes,
we also want to follow the best-practice of adding `override` to
members which are implemented as part of abstract classes. This
commit fixes all instances which will be flagged as part of the
custom `no-implicit-override-abstract` TSLint rule.

PR Close #42512
  • Loading branch information
devversion authored and AndrewKushnir committed Jul 12, 2021
1 parent 04642e7 commit b5ab7af
Show file tree
Hide file tree
Showing 113 changed files with 517 additions and 511 deletions.
4 changes: 2 additions & 2 deletions dev-infra/caretaker/check/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const exampleData = 'this is example data' as const;

/** A simple usage of the BaseModule to illustrate the workings built into the abstract class. */
class ConcreteBaseModule extends BaseModule<typeof exampleData> {
async retrieveData() {
override async retrieveData() {
return exampleData;
}
async printToTerminal() {}
override async printToTerminal() {}
}

describe('BaseModule', () => {
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/caretaker/check/ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type CiData = {
}[];

export class CiModule extends BaseModule<CiData> {
async retrieveData() {
override async retrieveData() {
const gitRepoWithApi = {api: this.git.github, ...this.git.remoteConfig};
const releaseTrains = await fetchActiveReleaseTrains(gitRepoWithApi);

Expand All @@ -52,7 +52,7 @@ export class CiModule extends BaseModule<CiData> {
return await Promise.all(ciResultPromises);
}

async printToTerminal() {
override async printToTerminal() {
const data = await this.data;
const minLabelLength = Math.max(...data.map(result => result.label.length));
info.group(bold(`CI`));
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/caretaker/check/g3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface G3StatsData {
}

export class G3Module extends BaseModule<G3StatsData|void> {
async retrieveData() {
override async retrieveData() {
const toCopyToG3 = this.getG3FileIncludeAndExcludeLists();
const latestSha = this.getLatestShas();

Expand All @@ -35,7 +35,7 @@ export class G3Module extends BaseModule<G3StatsData|void> {
latestSha.g3, latestSha.master, toCopyToG3.include, toCopyToG3.exclude);
}

async printToTerminal() {
override async printToTerminal() {
const stats = await this.data;
if (!stats) {
return;
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/caretaker/check/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type GithubQueryResult = {
const MAX_RETURNED_ISSUES = 20;

export class GithubQueriesModule extends BaseModule<GithubQueryResults|void> {
async retrieveData() {
override async retrieveData() {
// Non-null assertion is used here as the check for undefined immediately follows to confirm the
// assertion. Typescript's type filtering does not seem to work as needed to understand
// whether githubQueries is undefined or not.
Expand Down Expand Up @@ -95,7 +95,7 @@ export class GithubQueriesModule extends BaseModule<GithubQueryResults|void> {
return graphqlQuery;
}

async printToTerminal() {
override async printToTerminal() {
const queryResults = await this.data;
if (!queryResults) {
return;
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/caretaker/check/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ export const services: ServiceConfig[] = [
];

export class ServicesModule extends BaseModule<StatusCheckResult[]> {
async retrieveData() {
override async retrieveData() {
return Promise.all(services.map(service => this.getStatusFromStandardApi(service)));
}

async printToTerminal() {
override async printToTerminal() {
const statuses = await this.data;
const serviceNameMinLength = Math.max(...statuses.map(service => service.name.length));
info.group(bold('Service Statuses'));
Expand Down
8 changes: 4 additions & 4 deletions dev-infra/format/formatters/buildifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import {Formatter} from './base-formatter';
* Formatter for running buildifier against bazel related files.
*/
export class Buildifier extends Formatter {
name = 'buildifier';
override name = 'buildifier';

binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/buildifier');
override binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/buildifier');

defaultFileMatcher = ['**/*.bzl', '**/BUILD.bazel', '**/WORKSPACE', '**/BUILD'];
override defaultFileMatcher = ['**/*.bzl', '**/BUILD.bazel', '**/WORKSPACE', '**/BUILD'];

actions = {
override actions = {
check: {
commandFlags: `${BAZEL_WARNING_FLAG} --lint=warn --mode=check --format=json`,
callback:
Expand Down
8 changes: 4 additions & 4 deletions dev-infra/format/formatters/clang-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import {Formatter} from './base-formatter';
* Formatter for running clang-format against Typescript and Javascript files
*/
export class ClangFormat extends Formatter {
name = 'clang-format';
override name = 'clang-format';

binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/clang-format');
override binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/clang-format');

defaultFileMatcher = ['**/*.{t,j}s'];
override defaultFileMatcher = ['**/*.{t,j}s'];

actions = {
override actions = {
check: {
commandFlags: `--Werror -n -style=file`,
callback:
Expand Down
8 changes: 4 additions & 4 deletions dev-infra/format/formatters/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {Formatter} from './base-formatter';
* Formatter for running prettier against Typescript and Javascript files.
*/
export class Prettier extends Formatter {
name = 'prettier';
override name = 'prettier';

binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/prettier');
override binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/prettier');

defaultFileMatcher = ['**/*.{t,j}s'];
override defaultFileMatcher = ['**/*.{t,j}s'];

/**
* The configuration path of the prettier config, obtained during construction to prevent needing
Expand All @@ -30,7 +30,7 @@ export class Prettier extends Formatter {
private configPath =
this.config['prettier'] ? exec(`${this.binaryFilePath} --find-config-path .`).trim() : '';

actions = {
override actions = {
check: {
commandFlags: `--config ${this.configPath} --check`,
callback:
Expand Down
2 changes: 1 addition & 1 deletion dev-infra/pr/merge/strategies/api-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class GithubApiMergeStrategy extends MergeStrategy {
super(git);
}

async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
override async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
const {githubTargetBranch, prNumber, targetBranches, requiredBaseSha, needsCommitMessageFixup} =
pullRequest;
// If the pull request does not have its base branch set to any determined target
Expand Down
2 changes: 1 addition & 1 deletion dev-infra/pr/merge/strategies/autosquash-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class AutosquashMergeStrategy extends MergeStrategy {
* specific to the pull request merge.
* @returns A pull request failure or null in case of success.
*/
async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
override async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
const {prNumber, targetBranches, requiredBaseSha, needsCommitMessageFixup, githubTargetBranch} =
pullRequest;
// In case a required base is specified for this pull request, check if the pull
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/release/publish/actions/configure-next-as-major.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import {packageJsonPath} from '../constants';
export class ConfigureNextAsMajorAction extends ReleaseAction {
private _newVersion = semver.parse(`${this.active.next.version.major + 1}.0.0-next.0`)!;

async getDescription() {
override async getDescription() {
const {branchName} = this.active.next;
const newVersion = this._newVersion;
return `Configure the "${branchName}" branch to be released as major (v${newVersion}).`;
}

async perform() {
override async perform() {
const {branchName} = this.active.next;
const newVersion = this._newVersion;

Expand Down
4 changes: 2 additions & 2 deletions dev-infra/release/publish/actions/cut-lts-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export class CutLongTermSupportPatchAction extends ReleaseAction {
/** Promise resolving an object describing long-term support branches. */
ltsBranches = fetchLongTermSupportBranchesFromNpm(this.config);

async getDescription() {
override async getDescription() {
const {active} = await this.ltsBranches;
return `Cut a new release for an active LTS branch (${active.length} active).`;
}

async perform() {
override async perform() {
const ltsBranch = await this._promptForTargetLtsBranch();
const newVersion = semverInc(ltsBranch.version, 'patch');
const {pullRequest: {id}, releaseNotes} =
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/release/publish/actions/cut-new-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import {ReleaseAction} from '../actions';
export class CutNewPatchAction extends ReleaseAction {
private _newVersion = semverInc(this.active.latest.version, 'patch');

async getDescription() {
override async getDescription() {
const {branchName} = this.active.latest;
const newVersion = this._newVersion;
return `Cut a new patch release for the "${branchName}" branch (v${newVersion}).`;
}

async perform() {
override async perform() {
const {branchName} = this.active.latest;
const newVersion = this._newVersion;

Expand Down
4 changes: 2 additions & 2 deletions dev-infra/release/publish/actions/cut-next-prerelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export class CutNextPrereleaseAction extends ReleaseAction {
/** Promise resolving with the new version if a NPM next pre-release is cut. */
private _newVersion: Promise<semver.SemVer> = this._computeNewVersion();

async getDescription() {
override async getDescription() {
const {branchName} = this._getActivePrereleaseTrain();
const newVersion = await this._newVersion;
return `Cut a new next pre-release for the "${branchName}" branch (v${newVersion}).`;
}

async perform() {
override async perform() {
const releaseTrain = this._getActivePrereleaseTrain();
const {branchName} = releaseTrain;
const newVersion = await this._newVersion;
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/release/publish/actions/cut-release-candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import {ReleaseAction} from '../actions';
export class CutReleaseCandidateAction extends ReleaseAction {
private _newVersion = semverInc(this.active.releaseCandidate!.version, 'prerelease', 'rc');

async getDescription() {
override async getDescription() {
const newVersion = this._newVersion;
return `Cut a first release-candidate for the feature-freeze branch (v${newVersion}).`;
}

async perform() {
override async perform() {
const {branchName} = this.active.releaseCandidate!;
const newVersion = this._newVersion;

Expand Down
4 changes: 2 additions & 2 deletions dev-infra/release/publish/actions/cut-stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {invokeSetNpmDistCommand, invokeYarnInstallCommand} from '../external-com
export class CutStableAction extends ReleaseAction {
private _newVersion = this._computeNewVersion();

async getDescription() {
override async getDescription() {
const newVersion = this._newVersion;
return `Cut a stable release for the release-candidate branch (v${newVersion}).`;
}

async perform() {
override async perform() {
const {branchName} = this.active.releaseCandidate!;
const newVersion = this._newVersion;
const isNewMajor = this.active.releaseCandidate?.isMajor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import {changelogPath, packageJsonPath} from '../constants';
export class MoveNextIntoFeatureFreezeAction extends ReleaseAction {
private _newVersion = computeNewPrereleaseVersionForNext(this.active, this.config);

async getDescription() {
override async getDescription() {
const {branchName} = this.active.next;
const newVersion = await this._newVersion;
return `Move the "${branchName}" branch into feature-freeze phase (v${newVersion}).`;
}

async perform() {
override async perform() {
const newVersion = await this._newVersion;
const newBranch = `${newVersion.major}.${newVersion.minor}.x`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import {invokeSetNpmDistCommand, invokeYarnInstallCommand} from '../external-com
* @see {CutStableAction#perform} for more details.
*/
export class TagRecentMajorAsLatest extends ReleaseAction {
async getDescription() {
override async getDescription() {
return `Tag recently published major v${this.active.latest.version} as "next" in NPM.`;
}

async perform() {
override async perform() {
await this.checkoutUpstreamBranch(this.active.latest.branchName);
await invokeYarnInstallCommand(this.projectDir);
await invokeSetNpmDistCommand('latest', this.active.latest.version);
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/release/publish/test/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ describe('common release action logic', () => {
* release action class. This allows us to add unit tests.
*/
class TestAction extends ReleaseAction {
async getDescription() {
override async getDescription() {
return 'Test action';
}

async perform() {
override async perform() {
throw Error('Not implemented.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {dashCaseToCamelCase} from '../../util';
import {AnimationStyleNormalizer} from './animation_style_normalizer';

export class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
normalizePropertyName(propertyName: string, errors: string[]): string {
override normalizePropertyName(propertyName: string, errors: string[]): string {
return dashCaseToCamelCase(propertyName);
}

normalizeStyleValue(
override normalizeStyleValue(
userProvidedProperty: string, normalizedProperty: string, value: string|number,
errors: string[]): string {
let unit: string = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ class SuffixNormalizer extends AnimationStyleNormalizer {
super();
}

normalizePropertyName(propertyName: string, errors: string[]): string {
override normalizePropertyName(propertyName: string, errors: string[]): string {
return propertyName + this._suffix;
}

normalizeStyleValue(
override normalizeStyleValue(
userProvidedProperty: string, normalizedProperty: string, value: string|number,
errors: string[]): string {
return value + this._suffix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,11 @@ class SuffixNormalizer extends AnimationStyleNormalizer {
super();
}

normalizePropertyName(propertyName: string, errors: string[]): string {
override normalizePropertyName(propertyName: string, errors: string[]): string {
return propertyName + this._suffix;
}

normalizeStyleValue(
override normalizeStyleValue(
userProvidedProperty: string, normalizedProperty: string, value: string|number,
errors: string[]): string {
return value + this._suffix;
Expand All @@ -709,14 +709,14 @@ class ExactCssValueNormalizer extends AnimationStyleNormalizer {
super();
}

normalizePropertyName(propertyName: string, errors: string[]): string {
override normalizePropertyName(propertyName: string, errors: string[]): string {
if (!this._allowedValues[propertyName]) {
errors.push(`The CSS property \`${propertyName}\` is not allowed`);
}
return propertyName;
}

normalizeStyleValue(
override normalizeStyleValue(
userProvidedProperty: string, normalizedProperty: string, value: string|number,
errors: string[]): string {
const expectedValue = this._allowedValues[userProvidedProperty];
Expand Down
2 changes: 1 addition & 1 deletion packages/common/http/test/xsrf_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SampleTokenExtractor extends HttpXsrfTokenExtractor {
super();
}

getToken(): string|null {
override getToken(): string|null {
return this.token;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/i18n/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class NgLocaleLocalization extends NgLocalization {
super();
}

getPluralCategory(value: any, locale?: string): string {
override getPluralCategory(value: any, locale?: string): string {
const plural = getLocalePluralCase(locale || this.locale)(value);

switch (plural) {
Expand Down
Loading

0 comments on commit b5ab7af

Please sign in to comment.