From b5ab7aff433a67cddaa55e621d17b1a1b07b57c2 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Wed, 7 Jul 2021 19:58:22 +0200 Subject: [PATCH] refactor: add override keyword to members implementing abstract declarations (#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 --- dev-infra/caretaker/check/base.spec.ts | 4 +- dev-infra/caretaker/check/ci.ts | 4 +- dev-infra/caretaker/check/g3.ts | 4 +- dev-infra/caretaker/check/github.ts | 4 +- dev-infra/caretaker/check/services.ts | 4 +- dev-infra/format/formatters/buildifier.ts | 8 +- dev-infra/format/formatters/clang-format.ts | 8 +- dev-infra/format/formatters/prettier.ts | 8 +- dev-infra/pr/merge/strategies/api-merge.ts | 2 +- .../pr/merge/strategies/autosquash-merge.ts | 2 +- .../actions/configure-next-as-major.ts | 4 +- .../release/publish/actions/cut-lts-patch.ts | 4 +- .../release/publish/actions/cut-new-patch.ts | 4 +- .../publish/actions/cut-next-prerelease.ts | 4 +- .../publish/actions/cut-release-candidate.ts | 4 +- .../release/publish/actions/cut-stable.ts | 4 +- .../actions/move-next-into-feature-freeze.ts | 4 +- .../actions/tag-recent-major-as-latest.ts | 4 +- dev-infra/release/publish/test/common.spec.ts | 4 +- .../web_animations_style_normalizer.ts | 4 +- .../render/timeline_animation_engine_spec.ts | 4 +- .../transition_animation_engine_spec.ts | 8 +- packages/common/http/test/xsrf_spec.ts | 2 +- packages/common/src/i18n/localization.ts | 2 +- .../src/location/hash_location_strategy.ts | 16 +- .../common/src/location/location_strategy.ts | 16 +- .../common/src/location/platform_location.ts | 32 +-- .../dependencies/commonjs_dependency_host.ts | 4 +- .../src/dependencies/esm_dependency_host.ts | 4 +- .../src/dependencies/umd_dependency_host.ts | 4 +- .../program_based_entry_point_finder.ts | 5 +- .../targeted_entry_point_finder.ts | 5 +- .../tasks/queues/parallel_task_queue.ts | 2 +- .../tasks/queues/serial_task_queue.ts | 2 +- .../src/ngtsc/annotations/src/directive.ts | 4 +- .../src/ngtsc/annotations/src/ng_module.ts | 4 +- .../src/ngtsc/annotations/src/pipe.ts | 4 +- .../testing/src/mock_file_system_native.ts | 16 +- .../testing/src/mock_file_system_posix.ts | 16 +- .../testing/src/mock_file_system_windows.ts | 16 +- .../incremental/semantic_graph/src/graph.ts | 4 +- .../ngtsc/partial_evaluator/src/builtin.ts | 6 +- .../ngtsc/partial_evaluator/src/ts_helpers.ts | 6 +- .../src/ngtsc/transform/src/transform.ts | 4 +- .../ngtsc/typecheck/src/type_check_block.ts | 64 +++--- .../src/ngtsc/util/test/visitor_spec.ts | 2 +- packages/compiler/src/aot/static_reflector.ts | 2 +- packages/compiler/src/constant_pool.ts | 6 +- .../compiler/src/expression_parser/ast.ts | 46 ++--- .../compiler/src/i18n/serializers/xliff.ts | 6 +- .../compiler/src/i18n/serializers/xliff2.ts | 6 +- packages/compiler/src/i18n/serializers/xmb.ts | 6 +- packages/compiler/src/i18n/serializers/xtb.ts | 6 +- packages/compiler/src/ml_parser/ast.ts | 8 +- .../src/output/abstract_js_emitter.ts | 14 +- packages/compiler/src/output/js_emitter.ts | 2 +- packages/compiler/src/output/output_ast.ts | 190 +++++++++--------- packages/compiler/src/output/output_jit.ts | 2 +- packages/compiler/src/output/ts_emitter.ts | 16 +- .../src/schema/dom_element_schema_registry.ts | 24 ++- .../compiler/test/i18n/message_bundle_spec.ts | 6 +- .../testing/src/resource_loader_mock.ts | 2 +- .../activatedRouteSnapshotFragmentRule.ts | 2 +- .../google3/canActivateWithRedirectToRule.ts | 2 +- .../migrations/google3/dynamicQueriesRule.ts | 2 +- .../google3/explicitQueryTimingRule.ts | 2 +- .../google3/initialNavigationRule.ts | 2 +- .../google3/navigationExtrasOmissionsRule.ts | 2 +- .../google3/noMissingInjectableRule.ts | 2 +- .../noTemplateVariableAssignmentRule.ts | 2 +- .../relativeLinkResolutionDefaultRule.ts | 2 +- .../google3/rendererToRenderer2Rule.ts | 2 +- ...decoratedClassesWithDecoratedFieldsRule.ts | 2 +- .../migrations/google3/waitForAsyncRule.ts | 2 +- .../src/linker/component_factory_resolver.ts | 12 +- packages/core/src/linker/template_ref.ts | 2 +- .../core/src/linker/view_container_ref.ts | 26 +-- packages/core/src/render3/component_ref.ts | 28 +-- packages/core/src/render3/ng_module_ref.ts | 13 +- packages/core/src/sanitization/bypass.ts | 10 +- packages/core/src/view/entrypoint.ts | 2 +- packages/core/src/view/refs.ts | 26 +-- .../inherit_definition_feature_spec.ts | 2 +- .../core/test/render3/imported_renderer2.ts | 4 +- packages/core/testing/src/resolvers.ts | 8 +- .../elements/src/create-custom-element.ts | 8 +- .../test/component-factory-strategy_spec.ts | 12 +- .../abstract_form_group_directive.ts | 2 +- packages/forms/src/directives/ng_form.ts | 2 +- packages/forms/src/directives/ng_model.ts | 4 +- .../form_control_directive.ts | 4 +- .../reactive_directives/form_control_name.ts | 4 +- .../form_group_directive.ts | 2 +- .../reactive_directives/form_group_name.ts | 2 +- packages/forms/src/directives/validators.ts | 12 +- packages/forms/src/model.ts | 53 ++--- .../language-service/ivy/template_target.ts | 2 +- packages/language-service/src/template.ts | 8 +- .../language-service/src/typescript_host.ts | 2 +- packages/language-service/test/mocks.ts | 2 +- .../src/http-client-backend-service.ts | 12 +- .../test/fixtures/http-client-hero-service.ts | 12 +- .../resource_loader/resource_loader_cache.ts | 2 +- .../resource_loader/resource_loader_impl.ts | 2 +- .../src/dom/events/dom_events.ts | 4 +- .../src/dom/events/hammer_gestures.ts | 4 +- .../src/dom/events/key_events.ts | 4 +- .../src/security/dom_sanitization_service.ts | 12 +- .../test/dom/events/event_manager_spec.ts | 4 +- packages/platform-server/src/http.ts | 2 +- packages/router/test/router_preloader.spec.ts | 4 +- packages/service-worker/worker/src/assets.ts | 4 +- .../requireInternalWithUnderscoreRule.ts | 4 +- 113 files changed, 517 insertions(+), 511 deletions(-) diff --git a/dev-infra/caretaker/check/base.spec.ts b/dev-infra/caretaker/check/base.spec.ts index 58af0c2cf8..0850d11117 100644 --- a/dev-infra/caretaker/check/base.spec.ts +++ b/dev-infra/caretaker/check/base.spec.ts @@ -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 { - async retrieveData() { + override async retrieveData() { return exampleData; } - async printToTerminal() {} + override async printToTerminal() {} } describe('BaseModule', () => { diff --git a/dev-infra/caretaker/check/ci.ts b/dev-infra/caretaker/check/ci.ts index 41985b9f0c..756a6ef326 100644 --- a/dev-infra/caretaker/check/ci.ts +++ b/dev-infra/caretaker/check/ci.ts @@ -25,7 +25,7 @@ type CiData = { }[]; export class CiModule extends BaseModule { - async retrieveData() { + override async retrieveData() { const gitRepoWithApi = {api: this.git.github, ...this.git.remoteConfig}; const releaseTrains = await fetchActiveReleaseTrains(gitRepoWithApi); @@ -52,7 +52,7 @@ export class CiModule extends BaseModule { 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`)); diff --git a/dev-infra/caretaker/check/g3.ts b/dev-infra/caretaker/check/g3.ts index faefc9bd9f..07349e50fd 100644 --- a/dev-infra/caretaker/check/g3.ts +++ b/dev-infra/caretaker/check/g3.ts @@ -23,7 +23,7 @@ export interface G3StatsData { } export class G3Module extends BaseModule { - async retrieveData() { + override async retrieveData() { const toCopyToG3 = this.getG3FileIncludeAndExcludeLists(); const latestSha = this.getLatestShas(); @@ -35,7 +35,7 @@ export class G3Module extends BaseModule { latestSha.g3, latestSha.master, toCopyToG3.include, toCopyToG3.exclude); } - async printToTerminal() { + override async printToTerminal() { const stats = await this.data; if (!stats) { return; diff --git a/dev-infra/caretaker/check/github.ts b/dev-infra/caretaker/check/github.ts index f0178c5ec1..7075ce2ed0 100644 --- a/dev-infra/caretaker/check/github.ts +++ b/dev-infra/caretaker/check/github.ts @@ -45,7 +45,7 @@ type GithubQueryResult = { const MAX_RETURNED_ISSUES = 20; export class GithubQueriesModule extends BaseModule { - 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. @@ -95,7 +95,7 @@ export class GithubQueriesModule extends BaseModule { return graphqlQuery; } - async printToTerminal() { + override async printToTerminal() { const queryResults = await this.data; if (!queryResults) { return; diff --git a/dev-infra/caretaker/check/services.ts b/dev-infra/caretaker/check/services.ts index 3e0a348ca7..46364263a3 100644 --- a/dev-infra/caretaker/check/services.ts +++ b/dev-infra/caretaker/check/services.ts @@ -45,11 +45,11 @@ export const services: ServiceConfig[] = [ ]; export class ServicesModule extends BaseModule { - 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')); diff --git a/dev-infra/format/formatters/buildifier.ts b/dev-infra/format/formatters/buildifier.ts index 823200faa7..b18ba62a3b 100644 --- a/dev-infra/format/formatters/buildifier.ts +++ b/dev-infra/format/formatters/buildifier.ts @@ -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: diff --git a/dev-infra/format/formatters/clang-format.ts b/dev-infra/format/formatters/clang-format.ts index 971893b336..637f427223 100644 --- a/dev-infra/format/formatters/clang-format.ts +++ b/dev-infra/format/formatters/clang-format.ts @@ -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: diff --git a/dev-infra/format/formatters/prettier.ts b/dev-infra/format/formatters/prettier.ts index 519bc7c82e..e56da8fa67 100644 --- a/dev-infra/format/formatters/prettier.ts +++ b/dev-infra/format/formatters/prettier.ts @@ -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 @@ -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: diff --git a/dev-infra/pr/merge/strategies/api-merge.ts b/dev-infra/pr/merge/strategies/api-merge.ts index 8ff3c7143a..49f2cc3cf7 100644 --- a/dev-infra/pr/merge/strategies/api-merge.ts +++ b/dev-infra/pr/merge/strategies/api-merge.ts @@ -44,7 +44,7 @@ export class GithubApiMergeStrategy extends MergeStrategy { super(git); } - async merge(pullRequest: PullRequest): Promise { + override async merge(pullRequest: PullRequest): Promise { const {githubTargetBranch, prNumber, targetBranches, requiredBaseSha, needsCommitMessageFixup} = pullRequest; // If the pull request does not have its base branch set to any determined target diff --git a/dev-infra/pr/merge/strategies/autosquash-merge.ts b/dev-infra/pr/merge/strategies/autosquash-merge.ts index f4d72c4680..bff4e518e9 100644 --- a/dev-infra/pr/merge/strategies/autosquash-merge.ts +++ b/dev-infra/pr/merge/strategies/autosquash-merge.ts @@ -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 { + override async merge(pullRequest: PullRequest): Promise { const {prNumber, targetBranches, requiredBaseSha, needsCommitMessageFixup, githubTargetBranch} = pullRequest; // In case a required base is specified for this pull request, check if the pull diff --git a/dev-infra/release/publish/actions/configure-next-as-major.ts b/dev-infra/release/publish/actions/configure-next-as-major.ts index 09e993f916..f3003f2975 100644 --- a/dev-infra/release/publish/actions/configure-next-as-major.ts +++ b/dev-infra/release/publish/actions/configure-next-as-major.ts @@ -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; diff --git a/dev-infra/release/publish/actions/cut-lts-patch.ts b/dev-infra/release/publish/actions/cut-lts-patch.ts index 05dfda8597..52f1ae6ba8 100644 --- a/dev-infra/release/publish/actions/cut-lts-patch.ts +++ b/dev-infra/release/publish/actions/cut-lts-patch.ts @@ -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} = diff --git a/dev-infra/release/publish/actions/cut-new-patch.ts b/dev-infra/release/publish/actions/cut-new-patch.ts index 32db9ccc50..0e24e7d94a 100644 --- a/dev-infra/release/publish/actions/cut-new-patch.ts +++ b/dev-infra/release/publish/actions/cut-new-patch.ts @@ -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; diff --git a/dev-infra/release/publish/actions/cut-next-prerelease.ts b/dev-infra/release/publish/actions/cut-next-prerelease.ts index d652172d82..7d77ae6a6b 100644 --- a/dev-infra/release/publish/actions/cut-next-prerelease.ts +++ b/dev-infra/release/publish/actions/cut-next-prerelease.ts @@ -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 = 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; diff --git a/dev-infra/release/publish/actions/cut-release-candidate.ts b/dev-infra/release/publish/actions/cut-release-candidate.ts index 7a4b37cdd3..d480c9fa19 100644 --- a/dev-infra/release/publish/actions/cut-release-candidate.ts +++ b/dev-infra/release/publish/actions/cut-release-candidate.ts @@ -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; diff --git a/dev-infra/release/publish/actions/cut-stable.ts b/dev-infra/release/publish/actions/cut-stable.ts index 0d20ba28de..5259f41c0e 100644 --- a/dev-infra/release/publish/actions/cut-stable.ts +++ b/dev-infra/release/publish/actions/cut-stable.ts @@ -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; diff --git a/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts b/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts index 5d2652b3b2..a4c7f9eaf0 100644 --- a/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts +++ b/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts @@ -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`; diff --git a/dev-infra/release/publish/actions/tag-recent-major-as-latest.ts b/dev-infra/release/publish/actions/tag-recent-major-as-latest.ts index 98db8206fa..004441cfb4 100644 --- a/dev-infra/release/publish/actions/tag-recent-major-as-latest.ts +++ b/dev-infra/release/publish/actions/tag-recent-major-as-latest.ts @@ -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); diff --git a/dev-infra/release/publish/test/common.spec.ts b/dev-infra/release/publish/test/common.spec.ts index 263ca3f51f..e5bba5df63 100644 --- a/dev-infra/release/publish/test/common.spec.ts +++ b/dev-infra/release/publish/test/common.spec.ts @@ -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.'); } diff --git a/packages/animations/browser/src/dsl/style_normalization/web_animations_style_normalizer.ts b/packages/animations/browser/src/dsl/style_normalization/web_animations_style_normalizer.ts index 4ba6043bc5..6283f0d332 100644 --- a/packages/animations/browser/src/dsl/style_normalization/web_animations_style_normalizer.ts +++ b/packages/animations/browser/src/dsl/style_normalization/web_animations_style_normalizer.ts @@ -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 = ''; diff --git a/packages/animations/browser/test/render/timeline_animation_engine_spec.ts b/packages/animations/browser/test/render/timeline_animation_engine_spec.ts index c5b1b9ab28..c78b4273ab 100644 --- a/packages/animations/browser/test/render/timeline_animation_engine_spec.ts +++ b/packages/animations/browser/test/render/timeline_animation_engine_spec.ts @@ -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; diff --git a/packages/animations/browser/test/render/transition_animation_engine_spec.ts b/packages/animations/browser/test/render/transition_animation_engine_spec.ts index 273279a966..39ba85e8da 100644 --- a/packages/animations/browser/test/render/transition_animation_engine_spec.ts +++ b/packages/animations/browser/test/render/transition_animation_engine_spec.ts @@ -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; @@ -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]; diff --git a/packages/common/http/test/xsrf_spec.ts b/packages/common/http/test/xsrf_spec.ts index 6a176e6025..d9ff4f0021 100644 --- a/packages/common/http/test/xsrf_spec.ts +++ b/packages/common/http/test/xsrf_spec.ts @@ -17,7 +17,7 @@ class SampleTokenExtractor extends HttpXsrfTokenExtractor { super(); } - getToken(): string|null { + override getToken(): string|null { return this.token; } } diff --git a/packages/common/src/i18n/localization.ts b/packages/common/src/i18n/localization.ts index 096cadccbb..532c222500 100644 --- a/packages/common/src/i18n/localization.ts +++ b/packages/common/src/i18n/localization.ts @@ -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) { diff --git a/packages/common/src/location/hash_location_strategy.ts b/packages/common/src/location/hash_location_strategy.ts index 413e69b4a7..ceba0bc9bb 100644 --- a/packages/common/src/location/hash_location_strategy.ts +++ b/packages/common/src/location/hash_location_strategy.ts @@ -52,16 +52,16 @@ export class HashLocationStrategy extends LocationStrategy implements OnDestroy } } - onPopState(fn: LocationChangeListener): void { + override onPopState(fn: LocationChangeListener): void { this._removeListenerFns.push( this._platformLocation.onPopState(fn), this._platformLocation.onHashChange(fn)); } - getBaseHref(): string { + override getBaseHref(): string { return this._baseHref; } - path(includeHash: boolean = false): string { + override path(includeHash: boolean = false): string { // the hash value is always prefixed with a `#` // and if it is empty then it will stay empty let path = this._platformLocation.hash; @@ -70,12 +70,12 @@ export class HashLocationStrategy extends LocationStrategy implements OnDestroy return path.length > 0 ? path.substring(1) : path; } - prepareExternalUrl(internal: string): string { + override prepareExternalUrl(internal: string): string { const url = joinWithSlash(this._baseHref, internal); return url.length > 0 ? ('#' + url) : url; } - pushState(state: any, title: string, path: string, queryParams: string) { + override pushState(state: any, title: string, path: string, queryParams: string) { let url: string|null = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; @@ -83,7 +83,7 @@ export class HashLocationStrategy extends LocationStrategy implements OnDestroy this._platformLocation.pushState(state, title, url); } - replaceState(state: any, title: string, path: string, queryParams: string) { + override replaceState(state: any, title: string, path: string, queryParams: string) { let url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; @@ -91,11 +91,11 @@ export class HashLocationStrategy extends LocationStrategy implements OnDestroy this._platformLocation.replaceState(state, title, url); } - forward(): void { + override forward(): void { this._platformLocation.forward(); } - back(): void { + override back(): void { this._platformLocation.back(); } diff --git a/packages/common/src/location/location_strategy.ts b/packages/common/src/location/location_strategy.ts index d541784cd6..8e525944c4 100644 --- a/packages/common/src/location/location_strategy.ts +++ b/packages/common/src/location/location_strategy.ts @@ -135,41 +135,41 @@ export class PathLocationStrategy extends LocationStrategy implements OnDestroy } } - onPopState(fn: LocationChangeListener): void { + override onPopState(fn: LocationChangeListener): void { this._removeListenerFns.push( this._platformLocation.onPopState(fn), this._platformLocation.onHashChange(fn)); } - getBaseHref(): string { + override getBaseHref(): string { return this._baseHref; } - prepareExternalUrl(internal: string): string { + override prepareExternalUrl(internal: string): string { return joinWithSlash(this._baseHref, internal); } - path(includeHash: boolean = false): string { + override path(includeHash: boolean = false): string { const pathname = this._platformLocation.pathname + normalizeQueryParams(this._platformLocation.search); const hash = this._platformLocation.hash; return hash && includeHash ? `${pathname}${hash}` : pathname; } - pushState(state: any, title: string, url: string, queryParams: string) { + override pushState(state: any, title: string, url: string, queryParams: string) { const externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams)); this._platformLocation.pushState(state, title, externalUrl); } - replaceState(state: any, title: string, url: string, queryParams: string) { + override replaceState(state: any, title: string, url: string, queryParams: string) { const externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams)); this._platformLocation.replaceState(state, title, externalUrl); } - forward(): void { + override forward(): void { this._platformLocation.forward(); } - back(): void { + override back(): void { this._platformLocation.back(); } diff --git a/packages/common/src/location/platform_location.ts b/packages/common/src/location/platform_location.ts index 02afc7f491..80bf20ef13 100644 --- a/packages/common/src/location/platform_location.ts +++ b/packages/common/src/location/platform_location.ts @@ -128,48 +128,48 @@ export class BrowserPlatformLocation extends PlatformLocation { this._history = window.history; } - getBaseHrefFromDOM(): string { + override getBaseHrefFromDOM(): string { return getDOM().getBaseHref(this._doc)!; } - onPopState(fn: LocationChangeListener): VoidFunction { + override onPopState(fn: LocationChangeListener): VoidFunction { const window = getDOM().getGlobalEventTarget(this._doc, 'window'); window.addEventListener('popstate', fn, false); return () => window.removeEventListener('popstate', fn); } - onHashChange(fn: LocationChangeListener): VoidFunction { + override onHashChange(fn: LocationChangeListener): VoidFunction { const window = getDOM().getGlobalEventTarget(this._doc, 'window'); window.addEventListener('hashchange', fn, false); return () => window.removeEventListener('hashchange', fn); } - get href(): string { + override get href(): string { return this.location.href; } - get protocol(): string { + override get protocol(): string { return this.location.protocol; } - get hostname(): string { + override get hostname(): string { return this.location.hostname; } - get port(): string { + override get port(): string { return this.location.port; } - get pathname(): string { + override get pathname(): string { return this.location.pathname; } - get search(): string { + override get search(): string { return this.location.search; } - get hash(): string { + override get hash(): string { return this.location.hash; } - set pathname(newPath: string) { + override set pathname(newPath: string) { this.location.pathname = newPath; } - pushState(state: any, title: string, url: string): void { + override pushState(state: any, title: string, url: string): void { if (supportsState()) { this._history.pushState(state, title, url); } else { @@ -177,7 +177,7 @@ export class BrowserPlatformLocation extends PlatformLocation { } } - replaceState(state: any, title: string, url: string): void { + override replaceState(state: any, title: string, url: string): void { if (supportsState()) { this._history.replaceState(state, title, url); } else { @@ -185,11 +185,11 @@ export class BrowserPlatformLocation extends PlatformLocation { } } - forward(): void { + override forward(): void { this._history.forward(); } - back(): void { + override back(): void { this._history.back(); } @@ -197,7 +197,7 @@ export class BrowserPlatformLocation extends PlatformLocation { this._history.go(relativePosition); } - getState(): unknown { + override getState(): unknown { return this._history.state; } } diff --git a/packages/compiler-cli/ngcc/src/dependencies/commonjs_dependency_host.ts b/packages/compiler-cli/ngcc/src/dependencies/commonjs_dependency_host.ts index 1f31b9059b..ea57e6cbbd 100644 --- a/packages/compiler-cli/ngcc/src/dependencies/commonjs_dependency_host.ts +++ b/packages/compiler-cli/ngcc/src/dependencies/commonjs_dependency_host.ts @@ -16,11 +16,11 @@ import {DependencyHostBase} from './dependency_host'; * Helper functions for computing dependencies. */ export class CommonJsDependencyHost extends DependencyHostBase { - protected canSkipFile(fileContents: string): boolean { + protected override canSkipFile(fileContents: string): boolean { return !hasRequireCalls(fileContents); } - protected extractImports(file: AbsoluteFsPath, fileContents: string): Set { + protected override extractImports(file: AbsoluteFsPath, fileContents: string): Set { // Parse the source into a TypeScript AST and then walk it looking for imports and re-exports. const sf = ts.createSourceFile(file, fileContents, ts.ScriptTarget.ES2015, false, ts.ScriptKind.JS); diff --git a/packages/compiler-cli/ngcc/src/dependencies/esm_dependency_host.ts b/packages/compiler-cli/ngcc/src/dependencies/esm_dependency_host.ts index 77b8242733..f33c9f1f4c 100644 --- a/packages/compiler-cli/ngcc/src/dependencies/esm_dependency_host.ts +++ b/packages/compiler-cli/ngcc/src/dependencies/esm_dependency_host.ts @@ -23,7 +23,7 @@ export class EsmDependencyHost extends DependencyHostBase { // It has no relevance to capturing imports. private scanner = ts.createScanner(ts.ScriptTarget.Latest, /* skipTrivia */ true); - protected canSkipFile(fileContents: string): boolean { + protected override canSkipFile(fileContents: string): boolean { return !hasImportOrReexportStatements(fileContents); } @@ -43,7 +43,7 @@ export class EsmDependencyHost extends DependencyHostBase { * Specifically, backticked strings are particularly challenging since it is possible * to recursively nest backticks and TypeScript expressions within each other. */ - protected extractImports(file: AbsoluteFsPath, fileContents: string): Set { + protected override extractImports(file: AbsoluteFsPath, fileContents: string): Set { const imports = new Set(); const templateStack: ts.SyntaxKind[] = []; let lastToken: ts.SyntaxKind = ts.SyntaxKind.Unknown; diff --git a/packages/compiler-cli/ngcc/src/dependencies/umd_dependency_host.ts b/packages/compiler-cli/ngcc/src/dependencies/umd_dependency_host.ts index d3d97baf85..2274bbeffb 100644 --- a/packages/compiler-cli/ngcc/src/dependencies/umd_dependency_host.ts +++ b/packages/compiler-cli/ngcc/src/dependencies/umd_dependency_host.ts @@ -17,11 +17,11 @@ import {DependencyHostBase} from './dependency_host'; * Helper functions for computing dependencies. */ export class UmdDependencyHost extends DependencyHostBase { - protected canSkipFile(fileContents: string): boolean { + protected override canSkipFile(fileContents: string): boolean { return !hasRequireCalls(fileContents); } - protected extractImports(file: AbsoluteFsPath, fileContents: string): Set { + protected override extractImports(file: AbsoluteFsPath, fileContents: string): Set { // Parse the source into a TypeScript AST and then walk it looking for imports and re-exports. const sf = ts.createSourceFile(file, fileContents, ts.ScriptTarget.ES2015, false, ts.ScriptKind.JS); diff --git a/packages/compiler-cli/ngcc/src/entry_point_finder/program_based_entry_point_finder.ts b/packages/compiler-cli/ngcc/src/entry_point_finder/program_based_entry_point_finder.ts index 01f9330989..cb503e75c3 100644 --- a/packages/compiler-cli/ngcc/src/entry_point_finder/program_based_entry_point_finder.ts +++ b/packages/compiler-cli/ngcc/src/entry_point_finder/program_based_entry_point_finder.ts @@ -45,7 +45,7 @@ export class ProgramBasedEntryPointFinder extends TracingEntryPointFinder { * Return an array containing the external import paths that were extracted from the source-files * of the program defined by the tsconfig.json. */ - protected getInitialEntryPointPaths(): AbsoluteFsPath[] { + protected override getInitialEntryPointPaths(): AbsoluteFsPath[] { const moduleResolver = new ModuleResolver(this.fs, this.pathMappings, ['', '.ts', '/index.ts']); const host = new EsmDependencyHost(this.fs, moduleResolver); const dependencies = createDependencyInfo(); @@ -71,7 +71,8 @@ export class ProgramBasedEntryPointFinder extends TracingEntryPointFinder { * @returns the entry-point and its dependencies or `null` if the entry-point is not compiled by * Angular or cannot be determined. */ - protected getEntryPointWithDeps(entryPointPath: AbsoluteFsPath): EntryPointWithDependencies|null { + protected override getEntryPointWithDeps(entryPointPath: AbsoluteFsPath): + EntryPointWithDependencies|null { const entryPoints = this.findOrLoadEntryPoints(); if (!entryPoints.has(entryPointPath)) { return null; diff --git a/packages/compiler-cli/ngcc/src/entry_point_finder/targeted_entry_point_finder.ts b/packages/compiler-cli/ngcc/src/entry_point_finder/targeted_entry_point_finder.ts index 1c1e3099bc..c68e231772 100644 --- a/packages/compiler-cli/ngcc/src/entry_point_finder/targeted_entry_point_finder.ts +++ b/packages/compiler-cli/ngcc/src/entry_point_finder/targeted_entry_point_finder.ts @@ -83,7 +83,7 @@ export class TargetedEntryPointFinder extends TracingEntryPointFinder { /** * Return an array containing the `targetPath` from which to start the trace. */ - protected getInitialEntryPointPaths(): AbsoluteFsPath[] { + protected override getInitialEntryPointPaths(): AbsoluteFsPath[] { return [this.targetPath]; } @@ -97,7 +97,8 @@ export class TargetedEntryPointFinder extends TracingEntryPointFinder { * @returns the entry-point and its dependencies or `null` if the entry-point is not compiled by * Angular or cannot be determined. */ - protected getEntryPointWithDeps(entryPointPath: AbsoluteFsPath): EntryPointWithDependencies|null { + protected override getEntryPointWithDeps(entryPointPath: AbsoluteFsPath): + EntryPointWithDependencies|null { const packagePath = this.computePackagePath(entryPointPath); const entryPoint = getEntryPointInfo(this.fs, this.config, this.logger, packagePath, entryPointPath); diff --git a/packages/compiler-cli/ngcc/src/execution/tasks/queues/parallel_task_queue.ts b/packages/compiler-cli/ngcc/src/execution/tasks/queues/parallel_task_queue.ts index f747d33017..d6bfa10d86 100644 --- a/packages/compiler-cli/ngcc/src/execution/tasks/queues/parallel_task_queue.ts +++ b/packages/compiler-cli/ngcc/src/execution/tasks/queues/parallel_task_queue.ts @@ -27,7 +27,7 @@ export class ParallelTaskQueue extends BaseTaskQueue { this.blockedTasks = getBlockedTasks(dependencies); } - computeNextTask(): Task|null { + override computeNextTask(): Task|null { // Look for the first available (i.e. not blocked) task. // (NOTE: Since tasks are sorted by priority, the first available one is the best choice.) const nextTaskIdx = this.tasks.findIndex(task => !this.blockedTasks.has(task)); diff --git a/packages/compiler-cli/ngcc/src/execution/tasks/queues/serial_task_queue.ts b/packages/compiler-cli/ngcc/src/execution/tasks/queues/serial_task_queue.ts index 0fe5fdb064..b0515c8492 100644 --- a/packages/compiler-cli/ngcc/src/execution/tasks/queues/serial_task_queue.ts +++ b/packages/compiler-cli/ngcc/src/execution/tasks/queues/serial_task_queue.ts @@ -17,7 +17,7 @@ import {BaseTaskQueue} from './base_task_queue'; * before requesting the next one. */ export class SerialTaskQueue extends BaseTaskQueue { - computeNextTask(): Task|null { + override computeNextTask(): Task|null { const nextTask = this.tasks.shift() || null; if (nextTask) { diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts b/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts index c9a4f2a831..ba3447bfc3 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts @@ -64,7 +64,7 @@ export class DirectiveSymbol extends SemanticSymbol { super(decl); } - isPublicApiAffected(previousSymbol: SemanticSymbol): boolean { + override isPublicApiAffected(previousSymbol: SemanticSymbol): boolean { // Note: since components and directives have exactly the same items contributing to their // public API, it is okay for a directive to change into a component and vice versa without // the API being affected. @@ -83,7 +83,7 @@ export class DirectiveSymbol extends SemanticSymbol { !isArrayEqual(this.exportAs, previousSymbol.exportAs); } - isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean { + override isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean { // If the public API of the directive has changed, then so has its type-check API. if (this.isPublicApiAffected(previousSymbol)) { return true; diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts b/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts index d581d3df63..a148e04fcd 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts @@ -58,7 +58,7 @@ export class NgModuleSymbol extends SemanticSymbol { usedPipes: SemanticReference[] }[] = []; - isPublicApiAffected(previousSymbol: SemanticSymbol): boolean { + override isPublicApiAffected(previousSymbol: SemanticSymbol): boolean { if (!(previousSymbol instanceof NgModuleSymbol)) { return true; } @@ -104,7 +104,7 @@ export class NgModuleSymbol extends SemanticSymbol { return false; } - isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean { + override isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean { if (!(previousSymbol instanceof NgModuleSymbol)) { return true; } diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts b/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts index f623bfaf6a..aede86ed50 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts @@ -38,7 +38,7 @@ export class PipeSymbol extends SemanticSymbol { super(decl); } - isPublicApiAffected(previousSymbol: SemanticSymbol): boolean { + override isPublicApiAffected(previousSymbol: SemanticSymbol): boolean { if (!(previousSymbol instanceof PipeSymbol)) { return true; } @@ -46,7 +46,7 @@ export class PipeSymbol extends SemanticSymbol { return this.name !== previousSymbol.name; } - isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean { + override isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean { return this.isPublicApiAffected(previousSymbol); } } diff --git a/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_native.ts b/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_native.ts index bf3dd40597..a27c8f4648 100644 --- a/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_native.ts +++ b/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_native.ts @@ -21,20 +21,20 @@ export class MockFileSystemNative extends MockFileSystem { // Delegate to the real NodeJSFileSystem for these path related methods - resolve(...paths: string[]): AbsoluteFsPath { + override resolve(...paths: string[]): AbsoluteFsPath { return NodeJSFileSystem.prototype.resolve.call(this, this.pwd(), ...paths); } - dirname(file: T): T { + override dirname(file: T): T { return NodeJSFileSystem.prototype.dirname.call(this, file) as T; } - join(basePath: T, ...paths: string[]): T { + override join(basePath: T, ...paths: string[]): T { return NodeJSFileSystem.prototype.join.call(this, basePath, ...paths) as T; } - relative(from: T, to: T): PathSegment|AbsoluteFsPath { + override relative(from: T, to: T): PathSegment|AbsoluteFsPath { return NodeJSFileSystem.prototype.relative.call(this, from, to); } - basename(filePath: string, extension?: string): PathSegment { + override basename(filePath: string, extension?: string): PathSegment { return NodeJSFileSystem.prototype.basename.call(this, filePath, extension); } @@ -42,7 +42,7 @@ export class MockFileSystemNative extends MockFileSystem { return NodeJSFileSystem.prototype.isCaseSensitive.call(this); } - isRooted(path: string): boolean { + override isRooted(path: string): boolean { return NodeJSFileSystem.prototype.isRooted.call(this, path); } @@ -50,7 +50,7 @@ export class MockFileSystemNative extends MockFileSystem { return NodeJSFileSystem.prototype.isRoot.call(this, path); } - normalize(path: T): T { + override normalize(path: T): T { // When running in Windows, absolute paths are normalized to always include a drive letter. This // ensures that rooted posix paths used in tests will be normalized to real Windows paths, i.e. // including a drive letter. Note that the same normalization is done in emulated Windows mode @@ -63,7 +63,7 @@ export class MockFileSystemNative extends MockFileSystem { return NodeJSFileSystem.prototype.normalize.call(this, path) as T; } - protected splitPath(path: string): string[] { + protected override splitPath(path: string): string[] { return path.split(/[\\\/]/); } } diff --git a/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_posix.ts b/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_posix.ts index a8e84806b5..b526fc8484 100644 --- a/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_posix.ts +++ b/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_posix.ts @@ -12,36 +12,36 @@ import {AbsoluteFsPath, PathSegment, PathString} from '../../src/types'; import {MockFileSystem} from './mock_file_system'; export class MockFileSystemPosix extends MockFileSystem { - resolve(...paths: string[]): AbsoluteFsPath { + override resolve(...paths: string[]): AbsoluteFsPath { const resolved = p.posix.resolve(this.pwd(), ...paths); return this.normalize(resolved) as AbsoluteFsPath; } - dirname(file: T): T { + override dirname(file: T): T { return this.normalize(p.posix.dirname(file)) as T; } - join(basePath: T, ...paths: string[]): T { + override join(basePath: T, ...paths: string[]): T { return this.normalize(p.posix.join(basePath, ...paths)) as T; } - relative(from: T, to: T): PathSegment|AbsoluteFsPath { + override relative(from: T, to: T): PathSegment|AbsoluteFsPath { return this.normalize(p.posix.relative(from, to)) as PathSegment | AbsoluteFsPath; } - basename(filePath: string, extension?: string): PathSegment { + override basename(filePath: string, extension?: string): PathSegment { return p.posix.basename(filePath, extension) as PathSegment; } - isRooted(path: string): boolean { + override isRooted(path: string): boolean { return path.startsWith('/'); } - protected splitPath(path: T): string[] { + protected override splitPath(path: T): string[] { return path.split('/'); } - normalize(path: T): T { + override normalize(path: T): T { return path.replace(/^[a-z]:\//i, '/').replace(/\\/g, '/') as T; } } diff --git a/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_windows.ts b/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_windows.ts index e41f288e0c..def5ede041 100644 --- a/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_windows.ts +++ b/packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_windows.ts @@ -12,36 +12,36 @@ import {AbsoluteFsPath, PathSegment, PathString} from '../../src/types'; import {MockFileSystem} from './mock_file_system'; export class MockFileSystemWindows extends MockFileSystem { - resolve(...paths: string[]): AbsoluteFsPath { + override resolve(...paths: string[]): AbsoluteFsPath { const resolved = p.win32.resolve(this.pwd(), ...paths); return this.normalize(resolved as AbsoluteFsPath); } - dirname(path: T): T { + override dirname(path: T): T { return this.normalize(p.win32.dirname(path) as T); } - join(basePath: T, ...paths: string[]): T { + override join(basePath: T, ...paths: string[]): T { return this.normalize(p.win32.join(basePath, ...paths)) as T; } - relative(from: T, to: T): PathSegment|AbsoluteFsPath { + override relative(from: T, to: T): PathSegment|AbsoluteFsPath { return this.normalize(p.win32.relative(from, to)) as PathSegment | AbsoluteFsPath; } - basename(filePath: string, extension?: string): PathSegment { + override basename(filePath: string, extension?: string): PathSegment { return p.win32.basename(filePath, extension) as PathSegment; } - isRooted(path: string): boolean { + override isRooted(path: string): boolean { return /^([A-Z]:)?([\\\/]|$)/i.test(path); } - protected splitPath(path: T): string[] { + protected override splitPath(path: T): string[] { return path.split(/[\\\/]/); } - normalize(path: T): T { + override normalize(path: T): T { return path.replace(/^[\/\\]/i, 'C:/').replace(/\\/g, '/') as T; } } diff --git a/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/graph.ts b/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/graph.ts index 0c62c8b0d5..7baef8b304 100644 --- a/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/graph.ts +++ b/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/graph.ts @@ -35,11 +35,11 @@ export interface SemanticDependencyResult { * compilation. */ class OpaqueSymbol extends SemanticSymbol { - isPublicApiAffected(): false { + override isPublicApiAffected(): false { return false; } - isTypeCheckApiAffected(): false { + override isTypeCheckApiAffected(): false { return false; } } diff --git a/packages/compiler-cli/src/ngtsc/partial_evaluator/src/builtin.ts b/packages/compiler-cli/src/ngtsc/partial_evaluator/src/builtin.ts index 8f28792609..92ad9d60a0 100644 --- a/packages/compiler-cli/src/ngtsc/partial_evaluator/src/builtin.ts +++ b/packages/compiler-cli/src/ngtsc/partial_evaluator/src/builtin.ts @@ -16,7 +16,7 @@ export class ArraySliceBuiltinFn extends KnownFn { super(); } - evaluate(node: ts.CallExpression, args: ResolvedValueArray): ResolvedValue { + override evaluate(node: ts.CallExpression, args: ResolvedValueArray): ResolvedValue { if (args.length === 0) { return this.lhs; } else { @@ -30,7 +30,7 @@ export class ArrayConcatBuiltinFn extends KnownFn { super(); } - evaluate(node: ts.CallExpression, args: ResolvedValueArray): ResolvedValue { + override evaluate(node: ts.CallExpression, args: ResolvedValueArray): ResolvedValue { const result: ResolvedValueArray = [...this.lhs]; for (const arg of args) { if (arg instanceof DynamicValue) { @@ -46,7 +46,7 @@ export class ArrayConcatBuiltinFn extends KnownFn { } export class ObjectAssignBuiltinFn extends KnownFn { - evaluate(node: ts.CallExpression, args: ResolvedValueArray): ResolvedValue { + override evaluate(node: ts.CallExpression, args: ResolvedValueArray): ResolvedValue { if (args.length === 0) { return DynamicValue.fromUnsupportedSyntax(node); } diff --git a/packages/compiler-cli/src/ngtsc/partial_evaluator/src/ts_helpers.ts b/packages/compiler-cli/src/ngtsc/partial_evaluator/src/ts_helpers.ts index 109ef11292..5000ef201e 100644 --- a/packages/compiler-cli/src/ngtsc/partial_evaluator/src/ts_helpers.ts +++ b/packages/compiler-cli/src/ngtsc/partial_evaluator/src/ts_helpers.ts @@ -19,7 +19,7 @@ export class AssignHelperFn extends ObjectAssignBuiltinFn {} // Used for both `__spread()` and `__spreadArrays()` TypeScript helper functions. export class SpreadHelperFn extends KnownFn { - evaluate(node: ts.Node, args: ResolvedValueArray): ResolvedValueArray { + override evaluate(node: ts.Node, args: ResolvedValueArray): ResolvedValueArray { const result: ResolvedValueArray = []; for (const arg of args) { @@ -38,7 +38,7 @@ export class SpreadHelperFn extends KnownFn { // Used for `__spreadArray` TypeScript helper function. export class SpreadArrayHelperFn extends KnownFn { - evaluate(node: ts.Node, args: ResolvedValueArray): ResolvedValue { + override evaluate(node: ts.Node, args: ResolvedValueArray): ResolvedValue { if (args.length !== 2) { return DynamicValue.fromUnknown(node); } @@ -62,7 +62,7 @@ export class SpreadArrayHelperFn extends KnownFn { // Used for `__read` TypeScript helper function. export class ReadHelperFn extends KnownFn { - evaluate(node: ts.Node, args: ResolvedValueArray): ResolvedValue { + override evaluate(node: ts.Node, args: ResolvedValueArray): ResolvedValue { if (args.length !== 1) { // The `__read` helper accepts a second argument `n` but that case is not supported. return DynamicValue.fromUnknown(node); diff --git a/packages/compiler-cli/src/ngtsc/transform/src/transform.ts b/packages/compiler-cli/src/ngtsc/transform/src/transform.ts index 7d29340e8f..fd52a15a1e 100644 --- a/packages/compiler-cli/src/ngtsc/transform/src/transform.ts +++ b/packages/compiler-cli/src/ngtsc/transform/src/transform.ts @@ -61,7 +61,7 @@ class IvyCompilationVisitor extends Visitor { super(); } - visitClassDeclaration(node: ts.ClassDeclaration): + override visitClassDeclaration(node: ts.ClassDeclaration): VisitListEntryResult { // Determine if this class has an Ivy field that needs to be added, and compile the field // to an expression if so. @@ -87,7 +87,7 @@ class IvyTransformationVisitor extends Visitor { super(); } - visitClassDeclaration(node: ts.ClassDeclaration): + override visitClassDeclaration(node: ts.ClassDeclaration): VisitListEntryResult { // If this class is not registered in the map, it means that it doesn't have Angular decorators, // thus no further processing is required. diff --git a/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts b/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts index 0dff1183da..f905a4915d 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts @@ -192,14 +192,14 @@ class TcbElementOp extends TcbOp { super(); } - get optional() { + override get optional() { // The statement generated by this operation is only used for type-inference of the DOM // element's type and won't report diagnostics by itself, so the operation is marked as optional // to avoid generating statements for DOM elements that are never referenced. return true; } - execute(): ts.Identifier { + override execute(): ts.Identifier { const id = this.tcb.allocateId(); // Add the declaration of the element using document.createElement. const initializer = tsCreateElement(this.element.name); @@ -222,11 +222,11 @@ class TcbVariableOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): ts.Identifier { + override execute(): ts.Identifier { // Look for a context variable for the template. const ctx = this.scope.resolve(this.template); @@ -263,9 +263,9 @@ class TcbTemplateContextOp extends TcbOp { } // The declaration of the context variable is only needed when the context is actually referenced. - readonly optional = true; + override readonly optional = true; - execute(): ts.Identifier { + override execute(): ts.Identifier { // Allocate a template ctx variable and declare it with an 'any' type. The type of this variable // may be narrowed as a result of template guard conditions. const ctx = this.tcb.allocateId(); @@ -287,11 +287,11 @@ class TcbTemplateBodyOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): null { + override execute(): null { // An `if` will be constructed, within which the template's children will be type checked. The // `if` is used for two reasons: it creates a new syntactic scope, isolating variables declared // in the template's TCB from the outer context, and it allows any directives on the templates @@ -414,11 +414,11 @@ class TcbTextInterpolationOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): null { + override execute(): null { const expr = tcbExpression(this.binding.value, this.tcb, this.scope); this.scope.addStatement(ts.createExpressionStatement(expr)); return null; @@ -436,14 +436,14 @@ abstract class TcbDirectiveTypeOpBase extends TcbOp { super(); } - get optional() { + override get optional() { // The statement generated by this operation is only used to declare the directive's type and // won't report diagnostics by itself, so the operation is marked as optional to avoid // generating declarations for directives that don't have any inputs/outputs. return true; } - execute(): ts.Identifier { + override execute(): ts.Identifier { const dirRef = this.dir.ref as Reference>; const rawType = this.tcb.env.referenceType(this.dir.ref); @@ -543,9 +543,9 @@ class TcbReferenceOp extends TcbOp { // The statement generated by this operation is only used to for the Type Checker // so it can map a reference variable in the template directly to a node in the TCB. - readonly optional = true; + override readonly optional = true; - execute(): ts.Identifier { + override execute(): ts.Identifier { const id = this.tcb.allocateId(); let initializer = this.target instanceof TmplAstTemplate || this.target instanceof TmplAstElement ? @@ -591,9 +591,9 @@ class TcbInvalidReferenceOp extends TcbOp { } // The declaration of a missing reference is only needed when the reference is resolved. - readonly optional = true; + override readonly optional = true; - execute(): ts.Identifier { + override execute(): ts.Identifier { const id = this.tcb.allocateId(); this.scope.addStatement(tsCreateVariable(id, NULL_AS_ANY)); return id; @@ -619,13 +619,13 @@ class TcbDirectiveCtorOp extends TcbOp { super(); } - get optional() { + override get optional() { // The statement generated by this operation is only used to infer the directive's type and // won't report diagnostics by itself, so the operation is marked as optional. return true; } - execute(): ts.Identifier { + override execute(): ts.Identifier { const id = this.tcb.allocateId(); addExpressionIdentifier(id, ExpressionIdentifier.DIRECTIVE); addParseSpanInfo(id, this.node.startSourceSpan || this.node.sourceSpan); @@ -689,11 +689,11 @@ class TcbDirectiveInputsOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): null { + override execute(): null { let dirId: ts.Expression|null = null; // TODO(joost): report duplicate properties @@ -815,11 +815,11 @@ class TcbDirectiveCtorCircularFallbackOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): ts.Identifier { + override execute(): ts.Identifier { const id = this.tcb.allocateId(); const typeCtor = this.tcb.env.typeCtorFor(this.dir); const circularPlaceholder = ts.createCall( @@ -846,11 +846,11 @@ class TcbDomSchemaCheckerOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): ts.Expression|null { + override execute(): ts.Expression|null { if (this.checkElement) { this.tcb.domSchemaChecker.checkElement(this.tcb.id, this.element, this.tcb.schemas); } @@ -906,11 +906,11 @@ class TcbUnclaimedInputsOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): null { + override execute(): null { // `this.inputs` contains only those bindings not matched by any directive. These bindings go to // the element itself. let elId: ts.Expression|null = null; @@ -972,11 +972,11 @@ export class TcbDirectiveOutputsOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): null { + override execute(): null { let dirId: ts.Expression|null = null; const outputs = this.dir.outputs; @@ -1035,11 +1035,11 @@ class TcbUnclaimedOutputsOp extends TcbOp { super(); } - get optional() { + override get optional() { return false; } - execute(): null { + override execute(): null { let elId: ts.Expression|null = null; // TODO(alxhub): this could be more efficient. @@ -1103,9 +1103,9 @@ class TcbComponentContextCompletionOp extends TcbOp { super(); } - readonly optional = false; + override readonly optional = false; - execute(): null { + override execute(): null { const ctx = ts.createIdentifier('ctx'); const ctxDot = ts.createPropertyAccess(ctx, ''); markIgnoreDiagnostics(ctxDot); diff --git a/packages/compiler-cli/src/ngtsc/util/test/visitor_spec.ts b/packages/compiler-cli/src/ngtsc/util/test/visitor_spec.ts index b26e93e77d..4a48cd328d 100644 --- a/packages/compiler-cli/src/ngtsc/util/test/visitor_spec.ts +++ b/packages/compiler-cli/src/ngtsc/util/test/visitor_spec.ts @@ -13,7 +13,7 @@ import {makeProgram} from '../../testing'; import {visit, VisitListEntryResult, Visitor} from '../src/visitor'; class TestAstVisitor extends Visitor { - visitClassDeclaration(node: ts.ClassDeclaration): + override visitClassDeclaration(node: ts.ClassDeclaration): VisitListEntryResult { const name = node.name!.text; const statics = node.members.filter( diff --git a/packages/compiler/src/aot/static_reflector.ts b/packages/compiler/src/aot/static_reflector.ts index 563cf3b224..c6b8e98503 100644 --- a/packages/compiler/src/aot/static_reflector.ts +++ b/packages/compiler/src/aot/static_reflector.ts @@ -1056,7 +1056,7 @@ class PopulatedScope extends BindingScope { super(); } - resolve(name: string): any { + override resolve(name: string): any { return this.bindings.has(name) ? this.bindings.get(name) : BindingScope.missing; } } diff --git a/packages/compiler/src/constant_pool.ts b/packages/compiler/src/constant_pool.ts index 8b119f0094..a380c29807 100644 --- a/packages/compiler/src/constant_pool.ts +++ b/packages/compiler/src/constant_pool.ts @@ -62,7 +62,7 @@ class FixupExpression extends o.Expression { this.original = resolved; } - visitExpression(visitor: o.ExpressionVisitor, context: any): any { + override visitExpression(visitor: o.ExpressionVisitor, context: any): any { if (context === KEY_CONTEXT) { // When producing a key we want to traverse the constant not the // variable used to refer to it. @@ -72,11 +72,11 @@ class FixupExpression extends o.Expression { } } - isEquivalent(e: o.Expression): boolean { + override isEquivalent(e: o.Expression): boolean { return e instanceof FixupExpression && this.resolved.isEquivalent(e.resolved); } - isConstant() { + override isConstant() { return true; } diff --git a/packages/compiler/src/expression_parser/ast.ts b/packages/compiler/src/expression_parser/ast.ts index 50bac87750..3f06462024 100644 --- a/packages/compiler/src/expression_parser/ast.ts +++ b/packages/compiler/src/expression_parser/ast.ts @@ -65,7 +65,7 @@ export class Quote extends AST { public uninterpretedExpression: string, public location: any) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitQuote(this, context); } override toString(): string { @@ -74,13 +74,13 @@ export class Quote extends AST { } export class EmptyExpr extends AST { - visit(visitor: AstVisitor, context: any = null) { + override visit(visitor: AstVisitor, context: any = null) { // do nothing } } export class ImplicitReceiver extends AST { - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitImplicitReceiver(this, context); } } @@ -106,7 +106,7 @@ export class Chain extends AST { constructor(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public expressions: any[]) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitChain(this, context); } } @@ -117,7 +117,7 @@ export class Conditional extends AST { public falseExp: AST) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitConditional(this, context); } } @@ -128,7 +128,7 @@ export class PropertyRead extends ASTWithName { public receiver: AST, public name: string) { super(span, sourceSpan, nameSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitPropertyRead(this, context); } } @@ -139,7 +139,7 @@ export class PropertyWrite extends ASTWithName { public receiver: AST, public name: string, public value: AST) { super(span, sourceSpan, nameSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitPropertyWrite(this, context); } } @@ -150,7 +150,7 @@ export class SafePropertyRead extends ASTWithName { public receiver: AST, public name: string) { super(span, sourceSpan, nameSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitSafePropertyRead(this, context); } } @@ -160,7 +160,7 @@ export class KeyedRead extends AST { span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public receiver: AST, public key: AST) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitKeyedRead(this, context); } } @@ -170,7 +170,7 @@ export class SafeKeyedRead extends AST { span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public receiver: AST, public key: AST) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitSafeKeyedRead(this, context); } } @@ -181,7 +181,7 @@ export class KeyedWrite extends AST { public value: AST) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitKeyedWrite(this, context); } } @@ -192,7 +192,7 @@ export class BindingPipe extends ASTWithName { public args: any[], nameSpan: AbsoluteSourceSpan) { super(span, sourceSpan, nameSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitPipe(this, context); } } @@ -201,7 +201,7 @@ export class LiteralPrimitive extends AST { constructor(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public value: any) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitLiteralPrimitive(this, context); } } @@ -210,7 +210,7 @@ export class LiteralArray extends AST { constructor(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public expressions: any[]) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitLiteralArray(this, context); } } @@ -225,7 +225,7 @@ export class LiteralMap extends AST { public values: any[]) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitLiteralMap(this, context); } } @@ -236,7 +236,7 @@ export class Interpolation extends AST { public expressions: any[]) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitInterpolation(this, context); } } @@ -247,7 +247,7 @@ export class Binary extends AST { public right: AST) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitBinary(this, context); } } @@ -302,7 +302,7 @@ export class PrefixNot extends AST { constructor(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public expression: AST) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitPrefixNot(this, context); } } @@ -311,7 +311,7 @@ export class NonNullAssert extends AST { constructor(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public expression: AST) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitNonNullAssert(this, context); } } @@ -323,7 +323,7 @@ export class MethodCall extends ASTWithName { public argumentSpan: AbsoluteSourceSpan) { super(span, sourceSpan, nameSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitMethodCall(this, context); } } @@ -335,7 +335,7 @@ export class SafeMethodCall extends ASTWithName { public argumentSpan: AbsoluteSourceSpan) { super(span, sourceSpan, nameSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitSafeMethodCall(this, context); } } @@ -346,7 +346,7 @@ export class FunctionCall extends AST { public args: any[]) { super(span, sourceSpan); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitFunctionCall(this, context); } } @@ -368,7 +368,7 @@ export class ASTWithSource extends AST { new AbsoluteSourceSpan( absoluteOffset, source === null ? absoluteOffset : absoluteOffset + source.length)); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { if (visitor.visitASTWithSource) { return visitor.visitASTWithSource(this, context); } diff --git a/packages/compiler/src/i18n/serializers/xliff.ts b/packages/compiler/src/i18n/serializers/xliff.ts index 260221ba08..608eff8f59 100644 --- a/packages/compiler/src/i18n/serializers/xliff.ts +++ b/packages/compiler/src/i18n/serializers/xliff.ts @@ -34,7 +34,7 @@ const _CONTEXT_TAG = 'context'; // https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html // https://docs.oasis-open.org/xliff/v1.2/xliff-profile-html/xliff-profile-html-1.2.html export class Xliff extends Serializer { - write(messages: i18n.Message[], locale: string|null): string { + override write(messages: i18n.Message[], locale: string|null): string { const visitor = new _WriteVisitor(); const transUnits: xml.Node[] = []; @@ -92,7 +92,7 @@ export class Xliff extends Serializer { ]); } - load(content: string, url: string): + override load(content: string, url: string): {locale: string, i18nNodesByMsgId: {[msgId: string]: i18n.Node[]}} { // xliff to xml nodes const xliffParser = new XliffParser(); @@ -115,7 +115,7 @@ export class Xliff extends Serializer { return {locale: locale!, i18nNodesByMsgId}; } - digest(message: i18n.Message): string { + override digest(message: i18n.Message): string { return digest(message); } } diff --git a/packages/compiler/src/i18n/serializers/xliff2.ts b/packages/compiler/src/i18n/serializers/xliff2.ts index 624143dff2..f65ce94f4e 100644 --- a/packages/compiler/src/i18n/serializers/xliff2.ts +++ b/packages/compiler/src/i18n/serializers/xliff2.ts @@ -30,7 +30,7 @@ const _UNIT_TAG = 'unit'; // https://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html export class Xliff2 extends Serializer { - write(messages: i18n.Message[], locale: string|null): string { + override write(messages: i18n.Message[], locale: string|null): string { const visitor = new _WriteVisitor(); const units: xml.Node[] = []; @@ -85,7 +85,7 @@ export class Xliff2 extends Serializer { ]); } - load(content: string, url: string): + override load(content: string, url: string): {locale: string, i18nNodesByMsgId: {[msgId: string]: i18n.Node[]}} { // xliff to xml nodes const xliff2Parser = new Xliff2Parser(); @@ -108,7 +108,7 @@ export class Xliff2 extends Serializer { return {locale: locale!, i18nNodesByMsgId}; } - digest(message: i18n.Message): string { + override digest(message: i18n.Message): string { return decimalDigest(message); } } diff --git a/packages/compiler/src/i18n/serializers/xmb.ts b/packages/compiler/src/i18n/serializers/xmb.ts index 50d3a94754..3688454d30 100644 --- a/packages/compiler/src/i18n/serializers/xmb.ts +++ b/packages/compiler/src/i18n/serializers/xmb.ts @@ -39,7 +39,7 @@ const _DOCTYPE = ` `; export class Xmb extends Serializer { - write(messages: i18n.Message[], locale: string|null): string { + override write(messages: i18n.Message[], locale: string|null): string { const exampleVisitor = new ExampleVisitor(); const visitor = new _Visitor(); let rootNode = new xml.Tag(_MESSAGES_TAG); @@ -80,12 +80,12 @@ export class Xmb extends Serializer { ]); } - load(content: string, url: string): + override load(content: string, url: string): {locale: string, i18nNodesByMsgId: {[msgId: string]: i18n.Node[]}} { throw new Error('Unsupported'); } - digest(message: i18n.Message): string { + override digest(message: i18n.Message): string { return digest(message); } diff --git a/packages/compiler/src/i18n/serializers/xtb.ts b/packages/compiler/src/i18n/serializers/xtb.ts index 866a04b9f8..eb19ad64bd 100644 --- a/packages/compiler/src/i18n/serializers/xtb.ts +++ b/packages/compiler/src/i18n/serializers/xtb.ts @@ -19,11 +19,11 @@ const _TRANSLATION_TAG = 'translation'; const _PLACEHOLDER_TAG = 'ph'; export class Xtb extends Serializer { - write(messages: i18n.Message[], locale: string|null): string { + override write(messages: i18n.Message[], locale: string|null): string { throw new Error('Unsupported'); } - load(content: string, url: string): + override load(content: string, url: string): {locale: string, i18nNodesByMsgId: {[msgId: string]: i18n.Node[]}} { // xtb to xml nodes const xtbParser = new XtbParser(); @@ -54,7 +54,7 @@ export class Xtb extends Serializer { return {locale: locale!, i18nNodesByMsgId}; } - digest(message: i18n.Message): string { + override digest(message: i18n.Message): string { return digest(message); } diff --git a/packages/compiler/src/ml_parser/ast.ts b/packages/compiler/src/ml_parser/ast.ts index 274163561a..7b71ffe9af 100644 --- a/packages/compiler/src/ml_parser/ast.ts +++ b/packages/compiler/src/ml_parser/ast.ts @@ -26,7 +26,7 @@ export class Text extends NodeWithI18n { constructor(public value: string, sourceSpan: ParseSourceSpan, i18n?: I18nMeta) { super(sourceSpan, i18n); } - visit(visitor: Visitor, context: any): any { + override visit(visitor: Visitor, context: any): any { return visitor.visitText(this, context); } } @@ -37,7 +37,7 @@ export class Expansion extends NodeWithI18n { sourceSpan: ParseSourceSpan, public switchValueSourceSpan: ParseSourceSpan, i18n?: I18nMeta) { super(sourceSpan, i18n); } - visit(visitor: Visitor, context: any): any { + override visit(visitor: Visitor, context: any): any { return visitor.visitExpansion(this, context); } } @@ -59,7 +59,7 @@ export class Attribute extends NodeWithI18n { i18n?: I18nMeta) { super(sourceSpan, i18n); } - visit(visitor: Visitor, context: any): any { + override visit(visitor: Visitor, context: any): any { return visitor.visitAttribute(this, context); } } @@ -71,7 +71,7 @@ export class Element extends NodeWithI18n { public endSourceSpan: ParseSourceSpan|null = null, i18n?: I18nMeta) { super(sourceSpan, i18n); } - visit(visitor: Visitor, context: any): any { + override visit(visitor: Visitor, context: any): any { return visitor.visitElement(this, context); } } diff --git a/packages/compiler/src/output/abstract_js_emitter.ts b/packages/compiler/src/output/abstract_js_emitter.ts index 7ce1e95527..953ad11186 100644 --- a/packages/compiler/src/output/abstract_js_emitter.ts +++ b/packages/compiler/src/output/abstract_js_emitter.ts @@ -29,7 +29,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { constructor() { super(false); } - visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { + override visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { ctx.pushClass(stmt); this._visitClassConstructor(stmt, ctx); @@ -102,7 +102,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { } return null; } - visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { + override visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { ctx.print(stmt, `var ${stmt.name}`); if (stmt.value) { ctx.print(stmt, ' = '); @@ -111,7 +111,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { ctx.println(stmt, `;`); return null; } - visitCastExpr(ast: o.CastExpr, ctx: EmitterVisitorContext): any { + override visitCastExpr(ast: o.CastExpr, ctx: EmitterVisitorContext): any { ast.value.visitExpression(this, ctx); return null; } @@ -152,7 +152,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { ctx.print(ast, ')'); return null; } - visitFunctionExpr(ast: o.FunctionExpr, ctx: EmitterVisitorContext): any { + override visitFunctionExpr(ast: o.FunctionExpr, ctx: EmitterVisitorContext): any { ctx.print(ast, `function${ast.name ? ' ' + ast.name : ''}(`); this._visitParams(ast.params, ctx); ctx.println(ast, `) {`); @@ -162,7 +162,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { ctx.print(ast, `}`); return null; } - visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { + override visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { ctx.print(stmt, `function ${stmt.name}(`); this._visitParams(stmt.params, ctx); ctx.println(stmt, `) {`); @@ -172,7 +172,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { ctx.println(stmt, `}`); return null; } - visitTryCatchStmt(stmt: o.TryCatchStmt, ctx: EmitterVisitorContext): any { + override visitTryCatchStmt(stmt: o.TryCatchStmt, ctx: EmitterVisitorContext): any { ctx.println(stmt, `try {`); ctx.incIndent(); this.visitAllStatements(stmt.bodyStmts, ctx); @@ -217,7 +217,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { this.visitAllObjects(param => ctx.print(null, param.name), params, ctx, ','); } - getBuiltinMethodName(method: o.BuiltinMethod): string { + override getBuiltinMethodName(method: o.BuiltinMethod): string { let name: string; switch (method) { case o.BuiltinMethod.ConcatArray: diff --git a/packages/compiler/src/output/js_emitter.ts b/packages/compiler/src/output/js_emitter.ts index aa325a2155..1091dd1d3f 100644 --- a/packages/compiler/src/output/js_emitter.ts +++ b/packages/compiler/src/output/js_emitter.ts @@ -41,7 +41,7 @@ export class JavaScriptEmitter implements OutputEmitter { class JsEmitterVisitor extends AbstractJsEmitterVisitor { importsWithPrefixes = new Map(); - visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any { + override visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any { const {name, moduleName} = ast.value; if (moduleName) { let prefix = this.importsWithPrefixes.get(moduleName); diff --git a/packages/compiler/src/output/output_ast.ts b/packages/compiler/src/output/output_ast.ts index eccfd35dab..ae511e6e54 100644 --- a/packages/compiler/src/output/output_ast.ts +++ b/packages/compiler/src/output/output_ast.ts @@ -39,7 +39,7 @@ export class BuiltinType extends Type { constructor(public name: BuiltinTypeName, modifiers?: TypeModifier[]) { super(modifiers); } - visitType(visitor: TypeVisitor, context: any): any { + override visitType(visitor: TypeVisitor, context: any): any { return visitor.visitBuiltinType(this, context); } } @@ -49,7 +49,7 @@ export class ExpressionType extends Type { public value: Expression, modifiers?: TypeModifier[], public typeParams: Type[]|null = null) { super(modifiers); } - visitType(visitor: TypeVisitor, context: any): any { + override visitType(visitor: TypeVisitor, context: any): any { return visitor.visitExpressionType(this, context); } } @@ -59,7 +59,7 @@ export class ArrayType extends Type { constructor(public of: Type, modifiers?: TypeModifier[]) { super(modifiers); } - visitType(visitor: TypeVisitor, context: any): any { + override visitType(visitor: TypeVisitor, context: any): any { return visitor.visitArrayType(this, context); } } @@ -71,7 +71,7 @@ export class MapType extends Type { super(modifiers); this.valueType = valueType || null; } - visitType(visitor: TypeVisitor, context: any): any { + override visitType(visitor: TypeVisitor, context: any): any { return visitor.visitMapType(this, context); } } @@ -286,15 +286,15 @@ export class ReadVarExpr extends Expression { } } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof ReadVarExpr && this.name === e.name && this.builtin === e.builtin; } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitReadVarExpr(this, context); } @@ -311,15 +311,15 @@ export class TypeofExpr extends Expression { super(type, sourceSpan); } - visitExpression(visitor: ExpressionVisitor, context: any) { + override visitExpression(visitor: ExpressionVisitor, context: any) { return visitor.visitTypeofExpr(this, context); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof TypeofExpr && e.expr.isEquivalent(this.expr); } - isConstant(): boolean { + override isConstant(): boolean { return this.expr.isConstant(); } } @@ -329,15 +329,15 @@ export class WrappedNodeExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof WrappedNodeExpr && this.node === e.node; } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitWrappedNodeExpr(this, context); } } @@ -350,15 +350,15 @@ export class WriteVarExpr extends Expression { this.value = value; } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitWriteVarExpr(this, context); } @@ -381,16 +381,16 @@ export class WriteKeyExpr extends Expression { this.value = value; } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof WriteKeyExpr && this.receiver.isEquivalent(e.receiver) && this.index.isEquivalent(e.index) && this.value.isEquivalent(e.value); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitWriteKeyExpr(this, context); } } @@ -405,16 +405,16 @@ export class WritePropExpr extends Expression { this.value = value; } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof WritePropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name && this.value.isEquivalent(e.value); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitWritePropExpr(this, context); } } @@ -441,16 +441,16 @@ export class InvokeMethodExpr extends Expression { } } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof InvokeMethodExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name && this.builtin === e.builtin && areAllEquivalent(this.args, e.args); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitInvokeMethodExpr(this, context); } } @@ -463,16 +463,16 @@ export class InvokeFunctionExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof InvokeFunctionExpr && this.fn.isEquivalent(e.fn) && areAllEquivalent(this.args, e.args) && this.pure === e.pure; } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitInvokeFunctionExpr(this, context); } } @@ -485,18 +485,18 @@ export class TaggedTemplateExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof TaggedTemplateExpr && this.tag.isEquivalent(e.tag) && areAllEquivalentPredicate( this.template.elements, e.template.elements, (a, b) => a.text === b.text) && areAllEquivalent(this.template.expressions, e.template.expressions); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitTaggedTemplateExpr(this, context); } } @@ -509,16 +509,16 @@ export class InstantiateExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof InstantiateExpr && this.classExpr.isEquivalent(e.classExpr) && areAllEquivalent(this.args, e.args); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitInstantiateExpr(this, context); } } @@ -531,15 +531,15 @@ export class LiteralExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof LiteralExpr && this.value === e.value; } - isConstant() { + override isConstant() { return true; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitLiteralExpr(this, context); } } @@ -575,16 +575,16 @@ export class LocalizedString extends Expression { super(STRING_TYPE, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { // return e instanceof LocalizedString && this.message === e.message; return false; } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitLocalizedString(this, context); } @@ -696,16 +696,16 @@ export class ExternalExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof ExternalExpr && this.value.name === e.value.name && this.value.moduleName === e.value.moduleName && this.value.runtime === e.value.runtime; } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitExternalExpr(this, context); } } @@ -726,16 +726,16 @@ export class ConditionalExpr extends Expression { this.trueCase = trueCase; } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof ConditionalExpr && this.condition.isEquivalent(e.condition) && this.trueCase.isEquivalent(e.trueCase) && nullSafeIsEquivalent(this.falseCase, e.falseCase); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitConditionalExpr(this, context); } } @@ -746,15 +746,15 @@ export class NotExpr extends Expression { super(BOOL_TYPE, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof NotExpr && this.condition.isEquivalent(e.condition); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitNotExpr(this, context); } } @@ -764,15 +764,15 @@ export class AssertNotNull extends Expression { super(condition.type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof AssertNotNull && this.condition.isEquivalent(e.condition); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitAssertNotNullExpr(this, context); } } @@ -782,15 +782,15 @@ export class CastExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof CastExpr && this.value.isEquivalent(e.value); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitCastExpr(this, context); } } @@ -812,16 +812,16 @@ export class FunctionExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof FunctionExpr && areAllEquivalent(this.params, e.params) && areAllEquivalent(this.statements, e.statements); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitFunctionExpr(this, context); } @@ -839,16 +839,16 @@ export class UnaryOperatorExpr extends Expression { super(type || NUMBER_TYPE, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof UnaryOperatorExpr && this.operator === e.operator && this.expr.isEquivalent(e.expr); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitUnaryOperatorExpr(this, context); } } @@ -863,16 +863,16 @@ export class BinaryOperatorExpr extends Expression { this.lhs = lhs; } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof BinaryOperatorExpr && this.operator === e.operator && this.lhs.isEquivalent(e.lhs) && this.rhs.isEquivalent(e.rhs); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitBinaryOperatorExpr(this, context); } } @@ -885,16 +885,16 @@ export class ReadPropExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name; } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitReadPropExpr(this, context); } @@ -911,16 +911,16 @@ export class ReadKeyExpr extends Expression { super(type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof ReadKeyExpr && this.receiver.isEquivalent(e.receiver) && this.index.isEquivalent(e.index); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitReadKeyExpr(this, context); } @@ -937,14 +937,14 @@ export class LiteralArrayExpr extends Expression { this.entries = entries; } - isConstant() { + override isConstant() { return this.entries.every(e => e.isConstant()); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries); } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitLiteralArrayExpr(this, context); } } @@ -966,15 +966,15 @@ export class LiteralMapExpr extends Expression { } } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries); } - isConstant() { + override isConstant() { return this.entries.every(e => e.value.isConstant()); } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitLiteralMapExpr(this, context); } } @@ -984,15 +984,15 @@ export class CommaExpr extends Expression { super(parts[parts.length - 1].type, sourceSpan); } - isEquivalent(e: Expression): boolean { + override isEquivalent(e: Expression): boolean { return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts); } - isConstant() { + override isConstant() { return false; } - visitExpression(visitor: ExpressionVisitor, context: any): any { + override visitExpression(visitor: ExpressionVisitor, context: any): any { return visitor.visitCommaExpr(this, context); } } @@ -1086,11 +1086,11 @@ export class DeclareVarStmt extends Statement { super(modifiers, sourceSpan, leadingComments); this.type = type || (value && value.type) || null; } - isEquivalent(stmt: Statement): boolean { + override isEquivalent(stmt: Statement): boolean { return stmt instanceof DeclareVarStmt && this.name === stmt.name && (this.value ? !!stmt.value && this.value.isEquivalent(stmt.value) : !stmt.value); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitDeclareVarStmt(this, context); } } @@ -1104,11 +1104,11 @@ export class DeclareFunctionStmt extends Statement { super(modifiers, sourceSpan, leadingComments); this.type = type || null; } - isEquivalent(stmt: Statement): boolean { + override isEquivalent(stmt: Statement): boolean { return stmt instanceof DeclareFunctionStmt && areAllEquivalent(this.params, stmt.params) && areAllEquivalent(this.statements, stmt.statements); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitDeclareFunctionStmt(this, context); } } @@ -1119,10 +1119,10 @@ export class ExpressionStatement extends Statement { leadingComments?: LeadingComment[]) { super([], sourceSpan, leadingComments); } - isEquivalent(stmt: Statement): boolean { + override isEquivalent(stmt: Statement): boolean { return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitExpressionStmt(this, context); } } @@ -1134,10 +1134,10 @@ export class ReturnStatement extends Statement { leadingComments?: LeadingComment[]) { super([], sourceSpan, leadingComments); } - isEquivalent(stmt: Statement): boolean { + override isEquivalent(stmt: Statement): boolean { return stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitReturnStmt(this, context); } } @@ -1192,7 +1192,7 @@ export class ClassStmt extends Statement { leadingComments?: LeadingComment[]) { super(modifiers, sourceSpan, leadingComments); } - isEquivalent(stmt: Statement): boolean { + override isEquivalent(stmt: Statement): boolean { return stmt instanceof ClassStmt && this.name === stmt.name && nullSafeIsEquivalent(this.parent, stmt.parent) && areAllEquivalent(this.fields, stmt.fields) && @@ -1200,7 +1200,7 @@ export class ClassStmt extends Statement { this.constructorMethod.isEquivalent(stmt.constructorMethod) && areAllEquivalent(this.methods, stmt.methods); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitDeclareClassStmt(this, context); } } @@ -1213,12 +1213,12 @@ export class IfStmt extends Statement { leadingComments?: LeadingComment[]) { super([], sourceSpan, leadingComments); } - isEquivalent(stmt: Statement): boolean { + override isEquivalent(stmt: Statement): boolean { return stmt instanceof IfStmt && this.condition.isEquivalent(stmt.condition) && areAllEquivalent(this.trueCase, stmt.trueCase) && areAllEquivalent(this.falseCase, stmt.falseCase); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitIfStmt(this, context); } } @@ -1229,11 +1229,11 @@ export class TryCatchStmt extends Statement { sourceSpan: ParseSourceSpan|null = null, leadingComments?: LeadingComment[]) { super([], sourceSpan, leadingComments); } - isEquivalent(stmt: Statement): boolean { + override isEquivalent(stmt: Statement): boolean { return stmt instanceof TryCatchStmt && areAllEquivalent(this.bodyStmts, stmt.bodyStmts) && areAllEquivalent(this.catchStmts, stmt.catchStmts); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitTryCatchStmt(this, context); } } @@ -1245,10 +1245,10 @@ export class ThrowStmt extends Statement { leadingComments?: LeadingComment[]) { super([], sourceSpan, leadingComments); } - isEquivalent(stmt: ThrowStmt): boolean { + override isEquivalent(stmt: ThrowStmt): boolean { return stmt instanceof TryCatchStmt && this.error.isEquivalent(stmt.error); } - visitStatement(visitor: StatementVisitor, context: any): any { + override visitStatement(visitor: StatementVisitor, context: any): any { return visitor.visitThrowStmt(this, context); } } diff --git a/packages/compiler/src/output/output_jit.ts b/packages/compiler/src/output/output_jit.ts index 0923e91bee..95ec8cc940 100644 --- a/packages/compiler/src/output/output_jit.ts +++ b/packages/compiler/src/output/output_jit.ts @@ -119,7 +119,7 @@ export class JitEmitterVisitor extends AbstractJsEmitterVisitor { return result; } - visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any { + override visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any { this._emitReferenceToExternal(ast, this.reflector.resolveExternalReference(ast.value), ctx); return null; } diff --git a/packages/compiler/src/output/ts_emitter.ts b/packages/compiler/src/output/ts_emitter.ts index e7cad7060e..27ff79035e 100644 --- a/packages/compiler/src/output/ts_emitter.ts +++ b/packages/compiler/src/output/ts_emitter.ts @@ -118,7 +118,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return result; } - visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any { + override visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any { this._visitIdentifier(ast.value, ast.typeParams, ctx); return null; } @@ -129,7 +129,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return result; } - visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { + override visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { if (stmt.hasModifier(o.StmtModifier.Exported) && stmt.value instanceof o.ExternalExpr && !stmt.type) { // check for a reexport @@ -166,7 +166,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor throw new Error('Cannot visit a WrappedNodeExpr when outputting Typescript.'); } - visitCastExpr(ast: o.CastExpr, ctx: EmitterVisitorContext): any { + override visitCastExpr(ast: o.CastExpr, ctx: EmitterVisitorContext): any { ctx.print(ast, `(<`); ast.type!.visitType(this, ctx); ctx.print(ast, `>`); @@ -186,7 +186,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return null; } - visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { + override visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { ctx.pushClass(stmt); if (stmt.hasModifier(o.StmtModifier.Exported)) { ctx.print(stmt, `export `); @@ -267,7 +267,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor ctx.println(null, `}`); } - visitFunctionExpr(ast: o.FunctionExpr, ctx: EmitterVisitorContext): any { + override visitFunctionExpr(ast: o.FunctionExpr, ctx: EmitterVisitorContext): any { if (ast.name) { ctx.print(ast, 'function '); ctx.print(ast, ast.name); @@ -288,7 +288,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return null; } - visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { + override visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { if (stmt.hasModifier(o.StmtModifier.Exported)) { ctx.print(stmt, `export `); } @@ -304,7 +304,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return null; } - visitTryCatchStmt(stmt: o.TryCatchStmt, ctx: EmitterVisitorContext): any { + override visitTryCatchStmt(stmt: o.TryCatchStmt, ctx: EmitterVisitorContext): any { ctx.println(stmt, `try {`); ctx.incIndent(); this.visitAllStatements(stmt.bodyStmts, ctx); @@ -375,7 +375,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return null; } - getBuiltinMethodName(method: o.BuiltinMethod): string { + override getBuiltinMethodName(method: o.BuiltinMethod): string { let name: string; switch (method) { case o.BuiltinMethod.ConcatArray: diff --git a/packages/compiler/src/schema/dom_element_schema_registry.ts b/packages/compiler/src/schema/dom_element_schema_registry.ts index 2b6924c061..8b9708829c 100644 --- a/packages/compiler/src/schema/dom_element_schema_registry.ts +++ b/packages/compiler/src/schema/dom_element_schema_registry.ts @@ -291,7 +291,7 @@ export class DomElementSchemaRegistry extends ElementSchemaRegistry { }); } - hasProperty(tagName: string, propName: string, schemaMetas: SchemaMetadata[]): boolean { + override hasProperty(tagName: string, propName: string, schemaMetas: SchemaMetadata[]): boolean { if (schemaMetas.some((schema) => schema.name === NO_ERRORS_SCHEMA.name)) { return true; } @@ -312,7 +312,7 @@ export class DomElementSchemaRegistry extends ElementSchemaRegistry { return !!elementProperties[propName]; } - hasElement(tagName: string, schemaMetas: SchemaMetadata[]): boolean { + override hasElement(tagName: string, schemaMetas: SchemaMetadata[]): boolean { if (schemaMetas.some((schema) => schema.name === NO_ERRORS_SCHEMA.name)) { return true; } @@ -341,7 +341,8 @@ export class DomElementSchemaRegistry extends ElementSchemaRegistry { * above are assumed to have the 'NONE' security context, i.e. that they are safe inert * string values. Only specific well known attack vectors are assigned their appropriate context. */ - securityContext(tagName: string, propName: string, isAttribute: boolean): SecurityContext { + override securityContext(tagName: string, propName: string, isAttribute: boolean): + SecurityContext { if (isAttribute) { // NB: For security purposes, use the mapped property name, not the attribute name. propName = this.getMappedPropName(propName); @@ -359,15 +360,15 @@ export class DomElementSchemaRegistry extends ElementSchemaRegistry { return ctx ? ctx : SecurityContext.NONE; } - getMappedPropName(propName: string): string { + override getMappedPropName(propName: string): string { return _ATTR_TO_PROP[propName] || propName; } - getDefaultComponentElementName(): string { + override getDefaultComponentElementName(): string { return 'ng-component'; } - validateProperty(name: string): {error: boolean, msg?: string} { + override validateProperty(name: string): {error: boolean, msg?: string} { if (name.toLowerCase().startsWith('on')) { const msg = `Binding to event property '${name}' is disallowed for security reasons, ` + `please use (${name.slice(2)})=...` + @@ -379,7 +380,7 @@ export class DomElementSchemaRegistry extends ElementSchemaRegistry { } } - validateAttribute(name: string): {error: boolean, msg?: string} { + override validateAttribute(name: string): {error: boolean, msg?: string} { if (name.toLowerCase().startsWith('on')) { const msg = `Binding to event attribute '${name}' is disallowed for security reasons, ` + `please use (${name.slice(2)})=...`; @@ -389,7 +390,7 @@ export class DomElementSchemaRegistry extends ElementSchemaRegistry { } } - allKnownElementNames(): string[] { + override allKnownElementNames(): string[] { return Object.keys(this._schema); } @@ -399,12 +400,13 @@ export class DomElementSchemaRegistry extends ElementSchemaRegistry { return Object.keys(elementProperties).map(prop => _PROP_TO_ATTR[prop] ?? prop); } - normalizeAnimationStyleProperty(propName: string): string { + override normalizeAnimationStyleProperty(propName: string): string { return dashCaseToCamelCase(propName); } - normalizeAnimationStyleValue(camelCaseProp: string, userProvidedProp: string, val: string|number): - {error: string, value: string} { + override normalizeAnimationStyleValue( + camelCaseProp: string, userProvidedProp: string, + val: string|number): {error: string, value: string} { let unit: string = ''; const strVal = val.toString().trim(); let errorMsg: string = null!; diff --git a/packages/compiler/test/i18n/message_bundle_spec.ts b/packages/compiler/test/i18n/message_bundle_spec.ts index c1a2b23d08..8d2f7edce9 100644 --- a/packages/compiler/test/i18n/message_bundle_spec.ts +++ b/packages/compiler/test/i18n/message_bundle_spec.ts @@ -44,17 +44,17 @@ import {DEFAULT_INTERPOLATION_CONFIG} from '../../src/ml_parser/interpolation_co } class _TestSerializer extends Serializer { - write(messages: i18n.Message[]): string { + override write(messages: i18n.Message[]): string { return messages.map(msg => `${serializeNodes(msg.nodes)} (${msg.meaning}|${msg.description})`) .join('//'); } - load(content: string, url: string): + override load(content: string, url: string): {locale: string|null, i18nNodesByMsgId: {[id: string]: i18n.Node[]}} { return {locale: null, i18nNodesByMsgId: {}}; } - digest(msg: i18n.Message): string { + override digest(msg: i18n.Message): string { return msg.id || `default`; } } diff --git a/packages/compiler/testing/src/resource_loader_mock.ts b/packages/compiler/testing/src/resource_loader_mock.ts index 160fc968db..114c67b971 100644 --- a/packages/compiler/testing/src/resource_loader_mock.ts +++ b/packages/compiler/testing/src/resource_loader_mock.ts @@ -17,7 +17,7 @@ export class MockResourceLoader extends ResourceLoader { private _definitions = new Map(); private _requests: _PendingRequest[] = []; - get(url: string): Promise { + override get(url: string): Promise { const request = new _PendingRequest(url); this._requests.push(request); return request.getPromise(); diff --git a/packages/core/schematics/migrations/google3/activatedRouteSnapshotFragmentRule.ts b/packages/core/schematics/migrations/google3/activatedRouteSnapshotFragmentRule.ts index 4b55b2bc3c..23088f1991 100644 --- a/packages/core/schematics/migrations/google3/activatedRouteSnapshotFragmentRule.ts +++ b/packages/core/schematics/migrations/google3/activatedRouteSnapshotFragmentRule.ts @@ -12,7 +12,7 @@ import * as ts from 'typescript'; import {findFragmentAccesses, migrateActivatedRouteSnapshotFragment} from '../activated-route-snapshot-fragment/util'; export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { if (sourceFile.isDeclarationFile || program.isSourceFileFromExternalLibrary(sourceFile)) { return []; } diff --git a/packages/core/schematics/migrations/google3/canActivateWithRedirectToRule.ts b/packages/core/schematics/migrations/google3/canActivateWithRedirectToRule.ts index d920e136b4..4c45cf12a3 100644 --- a/packages/core/schematics/migrations/google3/canActivateWithRedirectToRule.ts +++ b/packages/core/schematics/migrations/google3/canActivateWithRedirectToRule.ts @@ -13,7 +13,7 @@ import {findLiteralsToMigrate, migrateLiteral} from '../can-activate-with-redire /** TSLint rule that removes canActivate from Route configs that also have redirectTo. */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const failures: RuleFailure[] = []; const printer = ts.createPrinter(); const literalsToMigrate = findLiteralsToMigrate(sourceFile); diff --git a/packages/core/schematics/migrations/google3/dynamicQueriesRule.ts b/packages/core/schematics/migrations/google3/dynamicQueriesRule.ts index 49e47adb57..e5749253c3 100644 --- a/packages/core/schematics/migrations/google3/dynamicQueriesRule.ts +++ b/packages/core/schematics/migrations/google3/dynamicQueriesRule.ts @@ -19,7 +19,7 @@ const FAILURE_MESSAGE = * TSLint rule that removes the `static` flag from dynamic queries. */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const printer = ts.createPrinter(); const failures: RuleFailure[] = []; const result = identifyDynamicQueryNodes(program.getTypeChecker(), sourceFile); diff --git a/packages/core/schematics/migrations/google3/explicitQueryTimingRule.ts b/packages/core/schematics/migrations/google3/explicitQueryTimingRule.ts index 20afbc54d6..b80b49f568 100644 --- a/packages/core/schematics/migrations/google3/explicitQueryTimingRule.ts +++ b/packages/core/schematics/migrations/google3/explicitQueryTimingRule.ts @@ -24,7 +24,7 @@ const FAILURE_MESSAGE = 'Query does not explicitly specify its timing. Read more * be applied in order to automatically migrate to the explicit query timing API. */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const typeChecker = program.getTypeChecker(); const queryVisitor = new NgQueryResolveVisitor(program.getTypeChecker()); const templateVisitor = new NgComponentTemplateVisitor(typeChecker); diff --git a/packages/core/schematics/migrations/google3/initialNavigationRule.ts b/packages/core/schematics/migrations/google3/initialNavigationRule.ts index 8f566288a3..a9c71f7905 100644 --- a/packages/core/schematics/migrations/google3/initialNavigationRule.ts +++ b/packages/core/schematics/migrations/google3/initialNavigationRule.ts @@ -19,7 +19,7 @@ import {InitialNavigationTransform} from '../initial-navigation/transform'; * TSLint rule that updates RouterModule `forRoot` options to be in line with v10 updates. */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const ruleName = this.ruleName; const typeChecker = program.getTypeChecker(); const sourceFiles = program.getSourceFiles().filter( diff --git a/packages/core/schematics/migrations/google3/navigationExtrasOmissionsRule.ts b/packages/core/schematics/migrations/google3/navigationExtrasOmissionsRule.ts index 7b3492b0e7..629b8ed98b 100644 --- a/packages/core/schematics/migrations/google3/navigationExtrasOmissionsRule.ts +++ b/packages/core/schematics/migrations/google3/navigationExtrasOmissionsRule.ts @@ -13,7 +13,7 @@ import {findLiteralsToMigrate, migrateLiteral} from '../../migrations/navigation /** TSLint rule that migrates `navigateByUrl` and `createUrlTree` calls to an updated signature. */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const failures: RuleFailure[] = []; const typeChecker = program.getTypeChecker(); const printer = ts.createPrinter(); diff --git a/packages/core/schematics/migrations/google3/noMissingInjectableRule.ts b/packages/core/schematics/migrations/google3/noMissingInjectableRule.ts index d4749efaf7..e9dedab1ba 100644 --- a/packages/core/schematics/migrations/google3/noMissingInjectableRule.ts +++ b/packages/core/schematics/migrations/google3/noMissingInjectableRule.ts @@ -21,7 +21,7 @@ import {MissingInjectableTransform} from '../missing-injectable/transform'; * Angular decorator (e.g. "@Injectable"). */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const ruleName = this.ruleName; const typeChecker = program.getTypeChecker(); const sourceFiles = program.getSourceFiles().filter( diff --git a/packages/core/schematics/migrations/google3/noTemplateVariableAssignmentRule.ts b/packages/core/schematics/migrations/google3/noTemplateVariableAssignmentRule.ts index 11950ca0a4..99a4a52159 100644 --- a/packages/core/schematics/migrations/google3/noTemplateVariableAssignmentRule.ts +++ b/packages/core/schematics/migrations/google3/noTemplateVariableAssignmentRule.ts @@ -20,7 +20,7 @@ const FAILURE_MESSAGE = 'Found assignment to template variable. This does not wo * Rule that reports if an Angular template contains property assignments to template variables. */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const typeChecker = program.getTypeChecker(); const templateVisitor = new NgComponentTemplateVisitor(typeChecker); const failures: RuleFailure[] = []; diff --git a/packages/core/schematics/migrations/google3/relativeLinkResolutionDefaultRule.ts b/packages/core/schematics/migrations/google3/relativeLinkResolutionDefaultRule.ts index 3725981830..4b3b45902b 100644 --- a/packages/core/schematics/migrations/google3/relativeLinkResolutionDefaultRule.ts +++ b/packages/core/schematics/migrations/google3/relativeLinkResolutionDefaultRule.ts @@ -14,7 +14,7 @@ import {TslintUpdateRecorder} from '../relative-link-resolution/google3/tslint_u import {RelativeLinkResolutionTransform} from '../relative-link-resolution/transform'; export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const typeChecker = program.getTypeChecker(); const ruleName = this.ruleName; const sourceFiles = program.getSourceFiles().filter( diff --git a/packages/core/schematics/migrations/google3/rendererToRenderer2Rule.ts b/packages/core/schematics/migrations/google3/rendererToRenderer2Rule.ts index 0155066eb7..c848bc3d3b 100644 --- a/packages/core/schematics/migrations/google3/rendererToRenderer2Rule.ts +++ b/packages/core/schematics/migrations/google3/rendererToRenderer2Rule.ts @@ -20,7 +20,7 @@ import {findRendererReferences} from '../renderer-to-renderer2/util'; * https://hackmd.angular.io/UTzUZTnPRA-cSa_4mHyfYw */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const typeChecker = program.getTypeChecker(); const printer = ts.createPrinter(); const failures: RuleFailure[] = []; diff --git a/packages/core/schematics/migrations/google3/undecoratedClassesWithDecoratedFieldsRule.ts b/packages/core/schematics/migrations/google3/undecoratedClassesWithDecoratedFieldsRule.ts index 9c9640bcfc..32b777c5f9 100644 --- a/packages/core/schematics/migrations/google3/undecoratedClassesWithDecoratedFieldsRule.ts +++ b/packages/core/schematics/migrations/google3/undecoratedClassesWithDecoratedFieldsRule.ts @@ -16,7 +16,7 @@ import {UndecoratedClassesWithDecoratedFieldsTransform} from '../undecorated-cla * https://hackmd.io/vuQfavzfRG6KUCtU7oK_EA */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const typeChecker = program.getTypeChecker(); const ruleName = this.ruleName; const sourceFiles = program.getSourceFiles().filter( diff --git a/packages/core/schematics/migrations/google3/waitForAsyncRule.ts b/packages/core/schematics/migrations/google3/waitForAsyncRule.ts index 44f374d60d..de947f0cf3 100644 --- a/packages/core/schematics/migrations/google3/waitForAsyncRule.ts +++ b/packages/core/schematics/migrations/google3/waitForAsyncRule.ts @@ -21,7 +21,7 @@ const newFunction = 'waitForAsync'; /** TSLint rule that migrates from `async` to `waitForAsync`. */ export class Rule extends Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { + override applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[] { const failures: RuleFailure[] = []; const asyncImportSpecifier = getImportSpecifier(sourceFile, '@angular/core/testing', deprecatedFunction); diff --git a/packages/core/src/linker/component_factory_resolver.ts b/packages/core/src/linker/component_factory_resolver.ts index 7446777f66..2d7cf0c645 100644 --- a/packages/core/src/linker/component_factory_resolver.ts +++ b/packages/core/src/linker/component_factory_resolver.ts @@ -79,11 +79,11 @@ export class CodegenComponentFactoryResolver implements ComponentFactoryResolver } export class ComponentFactoryBoundToModule extends ComponentFactory { - readonly selector: string; - readonly componentType: Type; - readonly ngContentSelectors: string[]; - readonly inputs: {propName: string, templateName: string}[]; - readonly outputs: {propName: string, templateName: string}[]; + override readonly selector: string; + override readonly componentType: Type; + override readonly ngContentSelectors: string[]; + override readonly inputs: {propName: string, templateName: string}[]; + override readonly outputs: {propName: string, templateName: string}[]; constructor(private factory: ComponentFactory, private ngModule: NgModuleRef) { super(); @@ -94,7 +94,7 @@ export class ComponentFactoryBoundToModule extends ComponentFactory { this.outputs = factory.outputs; } - create( + override create( injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string|any, ngModule?: NgModuleRef): ComponentRef { return this.factory.create( diff --git a/packages/core/src/linker/template_ref.ts b/packages/core/src/linker/template_ref.ts index 775815c494..cb7948a2ae 100644 --- a/packages/core/src/linker/template_ref.ts +++ b/packages/core/src/linker/template_ref.ts @@ -81,7 +81,7 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef { super(); } - createEmbeddedView(context: T): EmbeddedViewRef { + override createEmbeddedView(context: T): EmbeddedViewRef { const embeddedTView = this._declarationTContainer.tViews as TView; const embeddedLView = createLView( this._declarationLView, embeddedTView, context, LViewFlags.CheckAlways, null, diff --git a/packages/core/src/linker/view_container_ref.ts b/packages/core/src/linker/view_container_ref.ts index ed23fc3447..bf882bd609 100644 --- a/packages/core/src/linker/view_container_ref.ts +++ b/packages/core/src/linker/view_container_ref.ts @@ -194,16 +194,16 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef { super(); } - get element(): ElementRef { + override get element(): ElementRef { return createElementRef(this._hostTNode, this._hostLView); } - get injector(): Injector { + override get injector(): Injector { return new NodeInjector(this._hostTNode, this._hostLView); } /** @deprecated No replacement */ - get parentInjector(): Injector { + override get parentInjector(): Injector { const parentLocation = getParentInjectorLocation(this._hostTNode, this._hostLView); if (hasParentInjector(parentLocation)) { const parentView = getParentInjectorView(parentLocation, this._hostLView); @@ -217,29 +217,29 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef { } } - clear(): void { + override clear(): void { while (this.length > 0) { this.remove(this.length - 1); } } - get(index: number): ViewRef|null { + override get(index: number): ViewRef|null { const viewRefs = getViewRefs(this._lContainer); return viewRefs !== null && viewRefs[index] || null; } - get length(): number { + override get length(): number { return this._lContainer.length - CONTAINER_HEADER_OFFSET; } - createEmbeddedView(templateRef: TemplateRef, context?: C, index?: number): + override createEmbeddedView(templateRef: TemplateRef, context?: C, index?: number): EmbeddedViewRef { const viewRef = templateRef.createEmbeddedView(context || {}); this.insert(viewRef, index); return viewRef; } - createComponent( + override createComponent( componentFactory: ComponentFactory, index?: number|undefined, injector?: Injector|undefined, projectableNodes?: any[][]|undefined, ngModuleRef?: NgModuleRef|undefined): ComponentRef { @@ -260,7 +260,7 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef { return componentRef; } - insert(viewRef: ViewRef, index?: number): ViewRef { + override insert(viewRef: ViewRef, index?: number): ViewRef { const lView = (viewRef as R3ViewRef)._lView!; const tView = lView[TVIEW]; @@ -315,19 +315,19 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef { return viewRef; } - move(viewRef: ViewRef, newIndex: number): ViewRef { + override move(viewRef: ViewRef, newIndex: number): ViewRef { if (ngDevMode && viewRef.destroyed) { throw new Error('Cannot move a destroyed View in a ViewContainer!'); } return this.insert(viewRef, newIndex); } - indexOf(viewRef: ViewRef): number { + override indexOf(viewRef: ViewRef): number { const viewRefsArr = getViewRefs(this._lContainer); return viewRefsArr !== null ? viewRefsArr.indexOf(viewRef) : -1; } - remove(index?: number): void { + override remove(index?: number): void { const adjustedIdx = this._adjustIndex(index, -1); const detachedView = detachView(this._lContainer, adjustedIdx); @@ -343,7 +343,7 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef { } } - detach(index?: number): ViewRef|null { + override detach(index?: number): ViewRef|null { const adjustedIdx = this._adjustIndex(index, -1); const view = detachView(this._lContainer, adjustedIdx); diff --git a/packages/core/src/render3/component_ref.ts b/packages/core/src/render3/component_ref.ts index 2963007ecb..624788f281 100644 --- a/packages/core/src/render3/component_ref.ts +++ b/packages/core/src/render3/component_ref.ts @@ -47,7 +47,7 @@ export class ComponentFactoryResolver extends viewEngine_ComponentFactoryResolve super(); } - resolveComponentFactory(component: Type): viewEngine_ComponentFactory { + override resolveComponentFactory(component: Type): viewEngine_ComponentFactory { ngDevMode && assertComponentType(component); const componentDef = getComponentDef(component)!; return new ComponentFactory(componentDef, this.ngModule); @@ -103,16 +103,16 @@ function createChainedInjector(rootViewInjector: Injector, moduleInjector: Injec * Render3 implementation of {@link viewEngine_ComponentFactory}. */ export class ComponentFactory extends viewEngine_ComponentFactory { - selector: string; - componentType: Type; - ngContentSelectors: string[]; + override selector: string; + override componentType: Type; + override ngContentSelectors: string[]; isBoundToModule: boolean; - get inputs(): {propName: string; templateName: string;}[] { + override get inputs(): {propName: string; templateName: string;}[] { return toRefArray(this.componentDef.inputs); } - get outputs(): {propName: string; templateName: string;}[] { + override get outputs(): {propName: string; templateName: string;}[] { return toRefArray(this.componentDef.outputs); } @@ -130,7 +130,7 @@ export class ComponentFactory extends viewEngine_ComponentFactory { this.isBoundToModule = !!ngModule; } - create( + override create( injector: Injector, projectableNodes?: any[][]|undefined, rootSelectorOrNode?: any, ngModule?: viewEngine_NgModuleRef|undefined): viewEngine_ComponentRef { ngModule = ngModule || this.ngModule; @@ -247,10 +247,10 @@ export function injectComponentFactoryResolver(): viewEngine_ComponentFactoryRes * */ export class ComponentRef extends viewEngine_ComponentRef { - instance: T; - hostView: ViewRef; - changeDetectorRef: ViewEngine_ChangeDetectorRef; - componentType: Type; + override instance: T; + override hostView: ViewRef; + override changeDetectorRef: ViewEngine_ChangeDetectorRef; + override componentType: Type; constructor( componentType: Type, instance: T, public location: viewEngine_ElementRef, @@ -262,15 +262,15 @@ export class ComponentRef extends viewEngine_ComponentRef { this.componentType = componentType; } - get injector(): Injector { + override get injector(): Injector { return new NodeInjector(this._tNode, this._rootLView); } - destroy(): void { + override destroy(): void { this.hostView.destroy(); } - onDestroy(callback: () => void): void { + override onDestroy(callback: () => void): void { this.hostView.onDestroy(callback); } } diff --git a/packages/core/src/render3/ng_module_ref.ts b/packages/core/src/render3/ng_module_ref.ts index dae0f71b0c..a220086091 100644 --- a/packages/core/src/render3/ng_module_ref.ts +++ b/packages/core/src/render3/ng_module_ref.ts @@ -28,8 +28,8 @@ export class NgModuleRef extends viewEngine_NgModuleRef implements Interna _bootstrapComponents: Type[] = []; // tslint:disable-next-line:require-internal-with-underscore _r3Injector: R3Injector; - injector: Injector = this; - instance: T; + override injector: Injector = this; + override instance: T; destroyCbs: (() => void)[]|null = []; // When bootstrapping a module we have a dependency graph that looks like this: @@ -38,7 +38,8 @@ export class NgModuleRef extends viewEngine_NgModuleRef implements Interna // circular dependency which will result in a runtime error, because the injector doesn't // exist yet. We work around the issue by creating the ComponentFactoryResolver ourselves // and providing it, rather than letting the injector resolve it. - readonly componentFactoryResolver: ComponentFactoryResolver = new ComponentFactoryResolver(this); + override readonly componentFactoryResolver: ComponentFactoryResolver = + new ComponentFactoryResolver(this); constructor(ngModuleType: Type, public _parent: Injector|null) { super(); @@ -76,14 +77,14 @@ export class NgModuleRef extends viewEngine_NgModuleRef implements Interna return this._r3Injector.get(token, notFoundValue, injectFlags); } - destroy(): void { + override destroy(): void { ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed'); const injector = this._r3Injector; !injector.destroyed && injector.destroy(); this.destroyCbs!.forEach(fn => fn()); this.destroyCbs = null; } - onDestroy(callback: () => void): void { + override onDestroy(callback: () => void): void { ngDevMode && assertDefined(this.destroyCbs, 'NgModule already destroyed'); this.destroyCbs!.push(callback); } @@ -122,7 +123,7 @@ export class NgModuleFactory extends viewEngine_NgModuleFactory { } } - create(parentInjector: Injector|null): viewEngine_NgModuleRef { + override create(parentInjector: Injector|null): viewEngine_NgModuleRef { return new NgModuleRef(this.moduleType, parentInjector); } } diff --git a/packages/core/src/sanitization/bypass.ts b/packages/core/src/sanitization/bypass.ts index f45924688f..05364c268f 100644 --- a/packages/core/src/sanitization/bypass.ts +++ b/packages/core/src/sanitization/bypass.ts @@ -70,27 +70,27 @@ abstract class SafeValueImpl implements SafeValue { } class SafeHtmlImpl extends SafeValueImpl implements SafeHtml { - getTypeName() { + override getTypeName() { return BypassType.Html; } } class SafeStyleImpl extends SafeValueImpl implements SafeStyle { - getTypeName() { + override getTypeName() { return BypassType.Style; } } class SafeScriptImpl extends SafeValueImpl implements SafeScript { - getTypeName() { + override getTypeName() { return BypassType.Script; } } class SafeUrlImpl extends SafeValueImpl implements SafeUrl { - getTypeName() { + override getTypeName() { return BypassType.Url; } } class SafeResourceUrlImpl extends SafeValueImpl implements SafeResourceUrl { - getTypeName() { + override getTypeName() { return BypassType.ResourceUrl; } } diff --git a/packages/core/src/view/entrypoint.ts b/packages/core/src/view/entrypoint.ts index b66b51f7ba..0b96de0c32 100644 --- a/packages/core/src/view/entrypoint.ts +++ b/packages/core/src/view/entrypoint.ts @@ -64,7 +64,7 @@ class NgModuleFactory_ extends NgModuleFactory { super(); } - create(parentInjector: Injector|null): NgModuleRef { + override create(parentInjector: Injector|null): NgModuleRef { initServicesIfNeeded(); // Clone the NgModuleDefinition so that any tree shakeable provider definition // added to this instance of the NgModuleRef doesn't affect the cached copy. diff --git a/packages/core/src/view/refs.ts b/packages/core/src/view/refs.ts index b724fcc800..b33327a2b6 100644 --- a/packages/core/src/view/refs.ts +++ b/packages/core/src/view/refs.ts @@ -58,7 +58,7 @@ class ComponentFactory_ extends ComponentFactory { this.viewDefFactory = viewDefFactory; } - get inputs() { + override get inputs() { const inputsArr: {propName: string, templateName: string}[] = []; const inputs = this._inputs!; for (let propName in inputs) { @@ -68,7 +68,7 @@ class ComponentFactory_ extends ComponentFactory { return inputsArr; } - get outputs() { + override get outputs() { const outputsArr: {propName: string, templateName: string}[] = []; for (let propName in this._outputs) { const templateName = this._outputs[propName]; @@ -80,7 +80,7 @@ class ComponentFactory_ extends ComponentFactory { /** * Creates a new component. */ - create( + override create( injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string|any, ngModule?: NgModuleRef): ComponentRef { if (!ngModule) { @@ -100,9 +100,9 @@ class ComponentFactory_ extends ComponentFactory { } class ComponentRef_ extends ComponentRef { - public readonly hostView: ViewRef; - public readonly instance: any; - public readonly changeDetectorRef: ChangeDetectorRef; + public override readonly hostView: ViewRef; + public override readonly instance: any; + public override readonly changeDetectorRef: ChangeDetectorRef; private _elDef: NodeDef; constructor(private _view: ViewData, private _viewRef: ViewRef, private _component: any) { super(); @@ -111,20 +111,20 @@ class ComponentRef_ extends ComponentRef { this.changeDetectorRef = _viewRef; this.instance = _component; } - get location(): ElementRef { + override get location(): ElementRef { return new ElementRef(asElementData(this._view, this._elDef.nodeIndex).renderElement); } - get injector(): Injector { + override get injector(): Injector { return new Injector_(this._view, this._elDef); } - get componentType(): Type { + override get componentType(): Type { return this._component.constructor; } - destroy(): void { + override destroy(): void { this._viewRef.destroy(); } - onDestroy(callback: Function): void { + override onDestroy(callback: Function): void { this._viewRef.onDestroy(callback); } } @@ -350,12 +350,12 @@ class TemplateRef_ extends TemplateRef implements TemplateData { super(); } - createEmbeddedView(context: any): EmbeddedViewRef { + override createEmbeddedView(context: any): EmbeddedViewRef { return new ViewRef_(Services.createEmbeddedView( this._parentView, this._def, this._def.element!.template !, context)); } - get elementRef(): ElementRef { + override get elementRef(): ElementRef { return new ElementRef(asElementData(this._parentView, this._def.nodeIndex).renderElement); } } diff --git a/packages/core/test/acceptance/inherit_definition_feature_spec.ts b/packages/core/test/acceptance/inherit_definition_feature_spec.ts index 6a36e60771..4d569eae5d 100644 --- a/packages/core/test/acceptance/inherit_definition_feature_spec.ts +++ b/packages/core/test/acceptance/inherit_definition_feature_spec.ts @@ -329,7 +329,7 @@ describe('inheritance', () => { @Component({selector: 'my-comp', template: ''}) class MyComp extends UndecoratedBase { - @Input() input: any; + @Input() override input: any; } @Component({template: ''}) diff --git a/packages/core/test/render3/imported_renderer2.ts b/packages/core/test/render3/imported_renderer2.ts index 51a4854739..1f99c0760f 100644 --- a/packages/core/test/render3/imported_renderer2.ts +++ b/packages/core/test/render3/imported_renderer2.ts @@ -21,11 +21,11 @@ export class SimpleDomEventsPlugin extends EventManagerPlugin { super(doc); } - supports(eventName: string): boolean { + override supports(eventName: string): boolean { return true; } - addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { + override addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { let callback: EventListener = handler as EventListener; element.addEventListener(eventName, callback, false); return () => this.removeEventListener(element, eventName, callback); diff --git a/packages/core/testing/src/resolvers.ts b/packages/core/testing/src/resolvers.ts index 929acaecfc..ec58e2cb0d 100644 --- a/packages/core/testing/src/resolvers.ts +++ b/packages/core/testing/src/resolvers.ts @@ -86,25 +86,25 @@ abstract class OverrideResolver implements Resolver { export class DirectiveResolver extends OverrideResolver { - get type() { + override get type() { return Directive; } } export class ComponentResolver extends OverrideResolver { - get type() { + override get type() { return Component; } } export class PipeResolver extends OverrideResolver { - get type() { + override get type() { return Pipe; } } export class NgModuleResolver extends OverrideResolver { - get type() { + override get type() { return NgModule; } } diff --git a/packages/elements/src/create-custom-element.ts b/packages/elements/src/create-custom-element.ts index 3198d07f79..0da96e7f65 100644 --- a/packages/elements/src/create-custom-element.ts +++ b/packages/elements/src/create-custom-element.ts @@ -139,7 +139,7 @@ export function createCustomElement

( // field externs. So using quoted access to explicitly prevent renaming. static readonly['observedAttributes'] = Object.keys(attributeToPropertyInputs); - protected get ngElementStrategy(): NgElementStrategy { + protected override get ngElementStrategy(): NgElementStrategy { // NOTE: // Some polyfills (e.g. `document-register-element`) do not call the constructor, therefore // it is not safe to set `ngElementStrategy` in the constructor and assume it will be @@ -175,13 +175,13 @@ export function createCustomElement

( super(); } - attributeChangedCallback( + override attributeChangedCallback( attrName: string, oldValue: string|null, newValue: string, namespace?: string): void { const propName = attributeToPropertyInputs[attrName]!; this.ngElementStrategy.setInputValue(propName, newValue); } - connectedCallback(): void { + override connectedCallback(): void { // For historical reasons, some strategies may not have initialized the `events` property // until after `connect()` is run. Subscribe to `events` if it is available before running // `connect()` (in order to capture events emitted suring inittialization), otherwise @@ -208,7 +208,7 @@ export function createCustomElement

( } } - disconnectedCallback(): void { + override disconnectedCallback(): void { // Not using `this.ngElementStrategy` to avoid unnecessarily creating the `NgElementStrategy`. if (this._ngElementStrategy) { this._ngElementStrategy.disconnect(); diff --git a/packages/elements/test/component-factory-strategy_spec.ts b/packages/elements/test/component-factory-strategy_spec.ts index 00bcb97a50..41af6a31a9 100644 --- a/packages/elements/test/component-factory-strategy_spec.ts +++ b/packages/elements/test/component-factory-strategy_spec.ts @@ -451,16 +451,16 @@ export class FakeComponentFactory> extends ComponentFactory< instance: new this.ComponentClass(), }); - get selector(): string { + override get selector(): string { return 'fake-component'; } - get componentType(): Type { + override get componentType(): Type { return this.ComponentClass; } - get ngContentSelectors(): string[] { + override get ngContentSelectors(): string[] { return ['content-1', 'content-2']; } - get inputs(): {propName: string; templateName: string}[] { + override get inputs(): {propName: string; templateName: string}[] { return [ {propName: 'fooFoo', templateName: 'fooFoo'}, {propName: 'barBar', templateName: 'my-bar-bar'}, @@ -471,7 +471,7 @@ export class FakeComponentFactory> extends ComponentFactory< {propName: 'falsyZero', templateName: 'falsyZero'}, ]; } - get outputs(): {propName: string; templateName: string}[] { + override get outputs(): {propName: string; templateName: string}[] { return [ {propName: 'output1', templateName: 'templateOutput1'}, {propName: 'output2', templateName: 'templateOutput2'}, @@ -482,7 +482,7 @@ export class FakeComponentFactory> extends ComponentFactory< super(); } - create( + override create( injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string|any, ngModule?: NgModuleRef): ComponentRef { return this.componentRef; diff --git a/packages/forms/src/directives/abstract_form_group_directive.ts b/packages/forms/src/directives/abstract_form_group_directive.ts index c657f10ae3..4c48a7a3bd 100644 --- a/packages/forms/src/directives/abstract_form_group_directive.ts +++ b/packages/forms/src/directives/abstract_form_group_directive.ts @@ -52,7 +52,7 @@ export class AbstractFormGroupDirective extends ControlContainer implements OnIn * @description * The `FormGroup` bound to this directive. */ - get control(): FormGroup { + override get control(): FormGroup { return this.formDirective!.getFormGroup(this); } diff --git a/packages/forms/src/directives/ng_form.ts b/packages/forms/src/directives/ng_form.ts index 16e2a4aaa7..1c7e34e56f 100644 --- a/packages/forms/src/directives/ng_form.ts +++ b/packages/forms/src/directives/ng_form.ts @@ -156,7 +156,7 @@ export class NgForm extends ControlContainer implements Form, AfterViewInit { * @description * The internal `FormGroup` instance. */ - get control(): FormGroup { + override get control(): FormGroup { return this.form; } diff --git a/packages/forms/src/directives/ng_model.ts b/packages/forms/src/directives/ng_model.ts index 40d9a26ce9..827f95da69 100644 --- a/packages/forms/src/directives/ng_model.ts +++ b/packages/forms/src/directives/ng_model.ts @@ -136,7 +136,7 @@ const resolvedPromise = (() => Promise.resolve(null))(); exportAs: 'ngModel' }) export class NgModel extends NgControl implements OnChanges, OnDestroy { - public readonly control: FormControl = new FormControl(); + public override readonly control: FormControl = new FormControl(); // At runtime we coerce arbitrary values assigned to the "disabled" input to a "boolean". // This is not reflected in the type of the property because outside of templates, consumers @@ -258,7 +258,7 @@ export class NgModel extends NgControl implements OnChanges, OnDestroy { * * @param newValue The new value emitted by `ngModelChange`. */ - viewToModelUpdate(newValue: any): void { + override viewToModelUpdate(newValue: any): void { this.viewModel = newValue; this.update.emit(newValue); } diff --git a/packages/forms/src/directives/reactive_directives/form_control_directive.ts b/packages/forms/src/directives/reactive_directives/form_control_directive.ts index 53abe71a9d..ebcc91e2a4 100644 --- a/packages/forms/src/directives/reactive_directives/form_control_directive.ts +++ b/packages/forms/src/directives/reactive_directives/form_control_directive.ts @@ -157,7 +157,7 @@ export class FormControlDirective extends NgControl implements OnChanges, OnDest * @description * The `FormControl` bound to this directive. */ - get control(): FormControl { + override get control(): FormControl { return this.form; } @@ -167,7 +167,7 @@ export class FormControlDirective extends NgControl implements OnChanges, OnDest * * @param newValue The new value for the view model. */ - viewToModelUpdate(newValue: any): void { + override viewToModelUpdate(newValue: any): void { this.viewModel = newValue; this.update.emit(newValue); } diff --git a/packages/forms/src/directives/reactive_directives/form_control_name.ts b/packages/forms/src/directives/reactive_directives/form_control_name.ts index fb300c6942..183e1eb028 100644 --- a/packages/forms/src/directives/reactive_directives/form_control_name.ts +++ b/packages/forms/src/directives/reactive_directives/form_control_name.ts @@ -75,7 +75,7 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy { * Tracks the `FormControl` instance bound to the directive. */ // TODO(issue/24571): remove '!'. - readonly control!: FormControl; + override readonly control!: FormControl; /** * @description @@ -166,7 +166,7 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy { * * @param newValue The new value for the view model. */ - viewToModelUpdate(newValue: any): void { + override viewToModelUpdate(newValue: any): void { this.viewModel = newValue; this.update.emit(newValue); } diff --git a/packages/forms/src/directives/reactive_directives/form_group_directive.ts b/packages/forms/src/directives/reactive_directives/form_group_directive.ts index fe62635272..773771aa4f 100644 --- a/packages/forms/src/directives/reactive_directives/form_group_directive.ts +++ b/packages/forms/src/directives/reactive_directives/form_group_directive.ts @@ -140,7 +140,7 @@ export class FormGroupDirective extends ControlContainer implements Form, OnChan * @description * Returns the `FormGroup` bound to this directive. */ - get control(): FormGroup { + override get control(): FormGroup { return this.form; } diff --git a/packages/forms/src/directives/reactive_directives/form_group_name.ts b/packages/forms/src/directives/reactive_directives/form_group_name.ts index 7205397f76..1b2e8933b1 100644 --- a/packages/forms/src/directives/reactive_directives/form_group_name.ts +++ b/packages/forms/src/directives/reactive_directives/form_group_name.ts @@ -184,7 +184,7 @@ export class FormArrayName extends ControlContainer implements OnInit, OnDestroy * @description * The `FormArray` bound to this directive. */ - get control(): FormArray { + override get control(): FormArray { return this.formDirective!.getFormArray(this); } diff --git a/packages/forms/src/directives/validators.ts b/packages/forms/src/directives/validators.ts index b6ed662b55..801166c4d2 100644 --- a/packages/forms/src/directives/validators.ts +++ b/packages/forms/src/directives/validators.ts @@ -176,11 +176,11 @@ export class MaxValidator extends AbstractValidatorDirective implements OnChange */ @Input() max!: string|number; /** @internal */ - inputName = 'max'; + override inputName = 'max'; /** @internal */ - normalizeInput = (input: string): number => parseFloat(input); + override normalizeInput = (input: string): number => parseFloat(input); /** @internal */ - createValidator = (max: number): ValidatorFn => maxValidator(max); + override createValidator = (max: number): ValidatorFn => maxValidator(max); /** * Declare `ngOnChanges` lifecycle hook at the main directive level (vs keeping it in base class) * to avoid differences in handling inheritance of lifecycle hooks between Ivy and ViewEngine in @@ -236,11 +236,11 @@ export class MinValidator extends AbstractValidatorDirective implements OnChange */ @Input() min!: string|number; /** @internal */ - inputName = 'min'; + override inputName = 'min'; /** @internal */ - normalizeInput = (input: string): number => parseFloat(input); + override normalizeInput = (input: string): number => parseFloat(input); /** @internal */ - createValidator = (min: number): ValidatorFn => minValidator(min); + override createValidator = (min: number): ValidatorFn => minValidator(min); /** * Declare `ngOnChanges` lifecycle hook at the main directive level (vs keeping it in base class) * to avoid differences in handling inheritance of lifecycle hooks between Ivy and ViewEngine in diff --git a/packages/forms/src/model.ts b/packages/forms/src/model.ts index c5952f2fe3..039d66d9b7 100644 --- a/packages/forms/src/model.ts +++ b/packages/forms/src/model.ts @@ -1194,7 +1194,7 @@ export class FormControl extends AbstractControl { * event to update the model. * */ - setValue(value: any, options: { + override setValue(value: any, options: { onlySelf?: boolean, emitEvent?: boolean, emitModelToViewChange?: boolean, @@ -1217,7 +1217,7 @@ export class FormControl extends AbstractControl { * * @see `setValue` for options */ - patchValue(value: any, options: { + override patchValue(value: any, options: { onlySelf?: boolean, emitEvent?: boolean, emitModelToViewChange?: boolean, @@ -1244,7 +1244,8 @@ export class FormControl extends AbstractControl { * When false, no events are emitted. * */ - reset(formState: any = null, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { + override reset(formState: any = null, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): + void { this._applyFormState(formState); this.markAsPristine(options); this.markAsUntouched(options); @@ -1255,19 +1256,19 @@ export class FormControl extends AbstractControl { /** * @internal */ - _updateValue() {} + override _updateValue() {} /** * @internal */ - _anyControls(condition: Function): boolean { + override _anyControls(condition: Function): boolean { return false; } /** * @internal */ - _allControlsDisabled(): boolean { + override _allControlsDisabled(): boolean { return this.disabled; } @@ -1308,10 +1309,10 @@ export class FormControl extends AbstractControl { /** * @internal */ - _forEachChild(cb: Function): void {} + override _forEachChild(cb: Function): void {} /** @internal */ - _syncPendingControls(): boolean { + override _syncPendingControls(): boolean { if (this.updateOn === 'submit') { if (this._pendingDirty) this.markAsDirty(); if (this._pendingTouched) this.markAsTouched(); @@ -1564,8 +1565,8 @@ export class FormGroup extends AbstractControl { * observables emit events with the latest status and value when the control value is updated. * When false, no events are emitted. */ - setValue(value: {[key: string]: any}, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): - void { + override setValue( + value: {[key: string]: any}, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { this._checkAllValuesPresent(value); Object.keys(value).forEach(name => { this._throwIfControlMissing(name); @@ -1605,8 +1606,8 @@ export class FormGroup extends AbstractControl { * is updated. When false, no events are emitted. The configuration options are passed to * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method. */ - patchValue(value: {[key: string]: any}, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): - void { + override patchValue( + value: {[key: string]: any}, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { // Even though the `value` argument type doesn't allow `null` and `undefined` values, the // `patchValue` can be called recursively and inner data structures might have these values, so // we just ignore such cases when a field containing FormGroup instance receives `null` or @@ -1678,7 +1679,7 @@ export class FormGroup extends AbstractControl { * console.log(form.get('first').status); // 'DISABLED' * ``` */ - reset(value: any = {}, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { + override reset(value: any = {}, options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { this._forEachChild((control: AbstractControl, name: string) => { control.reset(value[name], {onlySelf: true, emitEvent: options.emitEvent}); }); @@ -1703,7 +1704,7 @@ export class FormGroup extends AbstractControl { } /** @internal */ - _syncPendingControls(): boolean { + override _syncPendingControls(): boolean { let subtreeUpdated = this._reduceChildren(false, (updated: boolean, child: AbstractControl) => { return child._syncPendingControls() ? true : updated; }); @@ -1725,7 +1726,7 @@ export class FormGroup extends AbstractControl { } /** @internal */ - _forEachChild(cb: (v: any, k: string) => void): void { + override _forEachChild(cb: (v: any, k: string) => void): void { Object.keys(this.controls).forEach(key => { // The list of controls can change (for ex. controls might be removed) while the loop // is running (as a result of invoking Forms API in `valueChanges` subscription), so we @@ -1744,12 +1745,12 @@ export class FormGroup extends AbstractControl { } /** @internal */ - _updateValue(): void { + override _updateValue(): void { (this as {value: any}).value = this._reduceValue(); } /** @internal */ - _anyControls(condition: Function): boolean { + override _anyControls(condition: Function): boolean { for (const controlName of Object.keys(this.controls)) { const control = this.controls[controlName]; if (this.contains(controlName) && condition(control)) { @@ -1780,7 +1781,7 @@ export class FormGroup extends AbstractControl { } /** @internal */ - _allControlsDisabled(): boolean { + override _allControlsDisabled(): boolean { for (const controlName of Object.keys(this.controls)) { if (this.controls[controlName].enabled) { return false; @@ -2021,7 +2022,7 @@ export class FormArray extends AbstractControl { * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity * updateValueAndValidity} method. */ - setValue(value: any[], options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { + override setValue(value: any[], options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { this._checkAllValuesPresent(value); value.forEach((newValue: any, index: number) => { this._throwIfControlMissing(index); @@ -2062,7 +2063,7 @@ export class FormArray extends AbstractControl { * is updated. When false, no events are emitted. The configuration options are passed to * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method. */ - patchValue(value: any[], options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { + override patchValue(value: any[], options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { // Even though the `value` argument type doesn't allow `null` and `undefined` values, the // `patchValue` can be called recursively and inner data structures might have these values, so // we just ignore such cases when a field containing FormArray instance receives `null` or @@ -2123,7 +2124,7 @@ export class FormArray extends AbstractControl { * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity * updateValueAndValidity} method. */ - reset(value: any = [], options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { + override reset(value: any = [], options: {onlySelf?: boolean, emitEvent?: boolean} = {}): void { this._forEachChild((control: AbstractControl, index: number) => { control.reset(value[index], {onlySelf: true, emitEvent: options.emitEvent}); }); @@ -2188,7 +2189,7 @@ export class FormArray extends AbstractControl { } /** @internal */ - _syncPendingControls(): boolean { + override _syncPendingControls(): boolean { let subtreeUpdated = this.controls.reduce((updated: boolean, child: AbstractControl) => { return child._syncPendingControls() ? true : updated; }, false); @@ -2210,21 +2211,21 @@ export class FormArray extends AbstractControl { } /** @internal */ - _forEachChild(cb: Function): void { + override _forEachChild(cb: Function): void { this.controls.forEach((control: AbstractControl, index: number) => { cb(control, index); }); } /** @internal */ - _updateValue(): void { + override _updateValue(): void { (this as {value: any}).value = this.controls.filter((control) => control.enabled || this.disabled) .map((control) => control.value); } /** @internal */ - _anyControls(condition: Function): boolean { + override _anyControls(condition: Function): boolean { return this.controls.some((control: AbstractControl) => control.enabled && condition(control)); } @@ -2243,7 +2244,7 @@ export class FormArray extends AbstractControl { } /** @internal */ - _allControlsDisabled(): boolean { + override _allControlsDisabled(): boolean { for (const control of this.controls) { if (control.enabled) return false; } diff --git a/packages/language-service/ivy/template_target.ts b/packages/language-service/ivy/template_target.ts index 6f748603b3..eccc3b3f07 100644 --- a/packages/language-service/ivy/template_target.ts +++ b/packages/language-service/ivy/template_target.ts @@ -147,7 +147,7 @@ export interface TwoWayBindingContext { * the key or value span of a node with key/value spans. */ class OutsideKeyValueMarkerAst extends e.AST { - visit(): null { + override visit(): null { return null; } } diff --git a/packages/language-service/src/template.ts b/packages/language-service/src/template.ts index c5aafa072d..e3edbc721e 100644 --- a/packages/language-service/src/template.ts +++ b/packages/language-service/src/template.ts @@ -87,9 +87,9 @@ abstract class BaseTemplate implements ng.TemplateSource { * `template` attribute in the decorator. */ export class InlineTemplate extends BaseTemplate { - public readonly fileName: string; - public readonly source: string; - public readonly span: ng.Span; + public override readonly fileName: string; + public override readonly source: string; + public override readonly span: ng.Span; constructor( templateNode: ts.StringLiteralLike, classDeclNode: ts.ClassDeclaration, @@ -119,7 +119,7 @@ export class InlineTemplate extends BaseTemplate { * a TS file. */ export class ExternalTemplate extends BaseTemplate { - public readonly span: ng.Span; + public override readonly span: ng.Span; constructor( public readonly source: string, public readonly fileName: string, diff --git a/packages/language-service/src/typescript_host.ts b/packages/language-service/src/typescript_host.ts index 14b92d03f4..9840fde62c 100644 --- a/packages/language-service/src/typescript_host.ts +++ b/packages/language-service/src/typescript_host.ts @@ -32,7 +32,7 @@ export class DummyHtmlParser extends HtmlParser { * Avoid loading resources in the language servcie by using a dummy loader. */ export class DummyResourceLoader extends ResourceLoader { - get(_url: string): Promise { + override get(_url: string): Promise { return Promise.resolve(''); } } diff --git a/packages/language-service/test/mocks.ts b/packages/language-service/test/mocks.ts index 56611fce47..46d9ea432c 100644 --- a/packages/language-service/test/mocks.ts +++ b/packages/language-service/test/mocks.ts @@ -174,7 +174,7 @@ export class DiagnosticContext { const pipeResolver = new PipeResolver(this.reflector); const elementSchemaRegistry = new DomElementSchemaRegistry(); const resourceLoader = new class extends ResourceLoader { - get(url: string): Promise { + override get(url: string): Promise { return Promise.resolve(''); } }; diff --git a/packages/misc/angular-in-memory-web-api/src/http-client-backend-service.ts b/packages/misc/angular-in-memory-web-api/src/http-client-backend-service.ts index 9074e146bb..92701755bf 100644 --- a/packages/misc/angular-in-memory-web-api/src/http-client-backend-service.ts +++ b/packages/misc/angular-in-memory-web-api/src/http-client-backend-service.ts @@ -64,19 +64,19 @@ export class HttpClientBackendService extends BackendService implements HttpBack } } - protected getJsonBody(req: HttpRequest): any { + protected override getJsonBody(req: HttpRequest): any { return req.body; } - protected getRequestMethod(req: HttpRequest): string { + protected override getRequestMethod(req: HttpRequest): string { return (req.method || 'get').toLowerCase(); } - protected createHeaders(headers: {[index: string]: string;}): HttpHeaders { + protected override createHeaders(headers: {[index: string]: string;}): HttpHeaders { return new HttpHeaders(headers); } - protected createQueryMap(search: string): Map { + protected override createQueryMap(search: string): Map { const map = new Map(); if (search) { const params = new HttpParams({fromString: search}); @@ -85,12 +85,12 @@ export class HttpClientBackendService extends BackendService implements HttpBack return map; } - protected createResponse$fromResponseOptions$(resOptions$: Observable): + protected override createResponse$fromResponseOptions$(resOptions$: Observable): Observable> { return resOptions$.pipe(map(opts => new HttpResponse(opts))); } - protected createPassThruBackend() { + protected override createPassThruBackend() { try { return new HttpXhrBackend(this.xhrFactory); } catch (ex) { diff --git a/packages/misc/angular-in-memory-web-api/test/fixtures/http-client-hero-service.ts b/packages/misc/angular-in-memory-web-api/test/fixtures/http-client-hero-service.ts index 658bdf439f..49f5e2e479 100644 --- a/packages/misc/angular-in-memory-web-api/test/fixtures/http-client-hero-service.ts +++ b/packages/misc/angular-in-memory-web-api/test/fixtures/http-client-hero-service.ts @@ -24,12 +24,12 @@ export class HttpClientHeroService extends HeroService { super(); } - getHeroes(): Observable { + override getHeroes(): Observable { return this.http.get(this.heroesUrl).pipe(catchError(this.handleError)); } // This get-by-id will 404 when id not found - getHero(id: number): Observable { + override getHero(id: number): Observable { const url = `${this.heroesUrl}/${id}`; return this.http.get(url).pipe(catchError(this.handleError)); } @@ -42,21 +42,21 @@ export class HttpClientHeroService extends HeroService { // .catch(this.handleError); // } - addHero(name: string): Observable { + override addHero(name: string): Observable { const hero = {name}; return this.http.post(this.heroesUrl, hero, cudOptions) .pipe(catchError(this.handleError)); } - deleteHero(hero: Hero|number): Observable { + override deleteHero(hero: Hero|number): Observable { const id = typeof hero === 'number' ? hero : hero.id; const url = `${this.heroesUrl}/${id}`; return this.http.delete(url, cudOptions).pipe(catchError(this.handleError)); } - searchHeroes(term: string): Observable { + override searchHeroes(term: string): Observable { term = term.trim(); // add safe, encoded search parameter if term is present const options = term ? {params: new HttpParams().set('name', term)} : {}; @@ -64,7 +64,7 @@ export class HttpClientHeroService extends HeroService { return this.http.get(this.heroesUrl, options).pipe(catchError(this.handleError)); } - updateHero(hero: Hero): Observable { + override updateHero(hero: Hero): Observable { return this.http.put(this.heroesUrl, hero, cudOptions).pipe(catchError(this.handleError)); } diff --git a/packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts b/packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts index fbc454796c..a18b29b9aa 100644 --- a/packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts +++ b/packages/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts @@ -29,7 +29,7 @@ export class CachedResourceLoader extends ResourceLoader { } } - get(url: string): Promise { + override get(url: string): Promise { if (this._cache.hasOwnProperty(url)) { return Promise.resolve(this._cache[url]); } else { diff --git a/packages/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts b/packages/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts index af0f7c5147..af176e9333 100644 --- a/packages/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts +++ b/packages/platform-browser-dynamic/src/resource_loader/resource_loader_impl.ts @@ -11,7 +11,7 @@ import {Injectable} from '@angular/core'; @Injectable() export class ResourceLoaderImpl extends ResourceLoader { - get(url: string): Promise { + override get(url: string): Promise { let resolve: (result: any) => void; let reject: (error: any) => void; const promise = new Promise((res, rej) => { diff --git a/packages/platform-browser/src/dom/events/dom_events.ts b/packages/platform-browser/src/dom/events/dom_events.ts index 3013d1e631..e3826727e3 100644 --- a/packages/platform-browser/src/dom/events/dom_events.ts +++ b/packages/platform-browser/src/dom/events/dom_events.ts @@ -19,11 +19,11 @@ export class DomEventsPlugin extends EventManagerPlugin { // This plugin should come last in the list of plugins, because it accepts all // events. - supports(eventName: string): boolean { + override supports(eventName: string): boolean { return true; } - addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { + override addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { element.addEventListener(eventName, handler as EventListener, false); return () => this.removeEventListener(element, eventName, handler as EventListener); } diff --git a/packages/platform-browser/src/dom/events/hammer_gestures.ts b/packages/platform-browser/src/dom/events/hammer_gestures.ts index 11f9a70f3c..882c44f15d 100644 --- a/packages/platform-browser/src/dom/events/hammer_gestures.ts +++ b/packages/platform-browser/src/dom/events/hammer_gestures.ts @@ -171,7 +171,7 @@ export class HammerGesturesPlugin extends EventManagerPlugin { super(doc); } - supports(eventName: string): boolean { + override supports(eventName: string): boolean { if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) { return false; } @@ -188,7 +188,7 @@ export class HammerGesturesPlugin extends EventManagerPlugin { return true; } - addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { + override addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { const zone = this.manager.getZone(); eventName = eventName.toLowerCase(); diff --git a/packages/platform-browser/src/dom/events/key_events.ts b/packages/platform-browser/src/dom/events/key_events.ts index 1ff05956cd..52217001de 100644 --- a/packages/platform-browser/src/dom/events/key_events.ts +++ b/packages/platform-browser/src/dom/events/key_events.ts @@ -88,7 +88,7 @@ export class KeyEventsPlugin extends EventManagerPlugin { * @param eventName The event name to query. * @return True if the named key event is supported. */ - supports(eventName: string): boolean { + override supports(eventName: string): boolean { return KeyEventsPlugin.parseEventName(eventName) != null; } @@ -100,7 +100,7 @@ export class KeyEventsPlugin extends EventManagerPlugin { * event object as an argument. * @returns The key event that was registered. */ - addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { + override addEventListener(element: HTMLElement, eventName: string, handler: Function): Function { const parsedEvent = KeyEventsPlugin.parseEventName(eventName)!; const outsideHandler = diff --git a/packages/platform-browser/src/security/dom_sanitization_service.ts b/packages/platform-browser/src/security/dom_sanitization_service.ts index d65e89adb2..c2ef38d612 100644 --- a/packages/platform-browser/src/security/dom_sanitization_service.ts +++ b/packages/platform-browser/src/security/dom_sanitization_service.ts @@ -153,7 +153,7 @@ export class DomSanitizerImpl extends DomSanitizer { super(); } - sanitize(ctx: SecurityContext, value: SafeValue|string|null): string|null { + override sanitize(ctx: SecurityContext, value: SafeValue|string|null): string|null { if (value == null) return null; switch (ctx) { case SecurityContext.NONE: @@ -190,19 +190,19 @@ export class DomSanitizerImpl extends DomSanitizer { } } - bypassSecurityTrustHtml(value: string): SafeHtml { + override bypassSecurityTrustHtml(value: string): SafeHtml { return bypassSanitizationTrustHtml(value); } - bypassSecurityTrustStyle(value: string): SafeStyle { + override bypassSecurityTrustStyle(value: string): SafeStyle { return bypassSanitizationTrustStyle(value); } - bypassSecurityTrustScript(value: string): SafeScript { + override bypassSecurityTrustScript(value: string): SafeScript { return bypassSanitizationTrustScript(value); } - bypassSecurityTrustUrl(value: string): SafeUrl { + override bypassSecurityTrustUrl(value: string): SafeUrl { return bypassSanitizationTrustUrl(value); } - bypassSecurityTrustResourceUrl(value: string): SafeResourceUrl { + override bypassSecurityTrustResourceUrl(value: string): SafeResourceUrl { return bypassSanitizationTrustResourceUrl(value); } } diff --git a/packages/platform-browser/test/dom/events/event_manager_spec.ts b/packages/platform-browser/test/dom/events/event_manager_spec.ts index 00277372b8..866afb8fb0 100644 --- a/packages/platform-browser/test/dom/events/event_manager_spec.ts +++ b/packages/platform-browser/test/dom/events/event_manager_spec.ts @@ -510,11 +510,11 @@ class FakeEventManagerPlugin extends EventManagerPlugin { super(doc); } - supports(eventName: string): boolean { + override supports(eventName: string): boolean { return this.supportedEvents.indexOf(eventName) > -1; } - addEventListener(element: any, eventName: string, handler: Function) { + override addEventListener(element: any, eventName: string, handler: Function) { this.eventHandler[eventName] = handler; return () => { delete this.eventHandler[eventName]; diff --git a/packages/platform-server/src/http.ts b/packages/platform-server/src/http.ts index 0154c026db..37b40d7984 100644 --- a/packages/platform-server/src/http.ts +++ b/packages/platform-server/src/http.ts @@ -124,7 +124,7 @@ export class ZoneClientBackend extends return this.wrap(request); } - protected delegate(request: HttpRequest): Observable> { + protected override delegate(request: HttpRequest): Observable> { return this.backend.handle(request); } } diff --git a/packages/router/test/router_preloader.spec.ts b/packages/router/test/router_preloader.spec.ts index b1e4a82478..d5401f177b 100644 --- a/packages/router/test/router_preloader.spec.ts +++ b/packages/router/test/router_preloader.spec.ts @@ -470,11 +470,11 @@ describe('RouterPreloader', () => { }); class BrokenModuleFactory extends NgModuleFactory { - moduleType: Type = LoadedModule1; + override moduleType: Type = LoadedModule1; constructor() { super(); } - create(_parentInjector: Injector|null): NgModuleRef { + override create(_parentInjector: Injector|null): NgModuleRef { throw 'Error: Broken module'; } } diff --git a/packages/service-worker/worker/src/assets.ts b/packages/service-worker/worker/src/assets.ts index c29707a45f..ec33c3b7a4 100644 --- a/packages/service-worker/worker/src/assets.ts +++ b/packages/service-worker/worker/src/assets.ts @@ -499,7 +499,7 @@ export abstract class AssetGroup { * An `AssetGroup` that prefetches all of its resources during initialization. */ export class PrefetchAssetGroup extends AssetGroup { - async initializeFully(updateFrom?: UpdateSource): Promise { + override async initializeFully(updateFrom?: UpdateSource): Promise { // Open the cache which actually holds requests. const cache = await this.cache; @@ -573,7 +573,7 @@ export class PrefetchAssetGroup extends AssetGroup { } export class LazyAssetGroup extends AssetGroup { - async initializeFully(updateFrom?: UpdateSource): Promise { + override async initializeFully(updateFrom?: UpdateSource): Promise { // No action necessary if no update source is available - resources managed in this group // are all lazily loaded, so there's nothing to initialize. if (updateFrom === undefined) { diff --git a/tools/tslint/requireInternalWithUnderscoreRule.ts b/tools/tslint/requireInternalWithUnderscoreRule.ts index 9f73e5f434..3ce981bf8c 100644 --- a/tools/tslint/requireInternalWithUnderscoreRule.ts +++ b/tools/tslint/requireInternalWithUnderscoreRule.ts @@ -12,7 +12,7 @@ import {AbstractRule} from 'tslint/lib/rules'; import * as ts from 'typescript'; export class Rule extends AbstractRule { - public apply(sourceFile: ts.SourceFile): RuleFailure[] { + override apply(sourceFile: ts.SourceFile): RuleFailure[] { const typedefWalker = new TypedefWalker(sourceFile, this.getOptions()); return this.applyWithWalker(typedefWalker); } @@ -47,6 +47,6 @@ class TypedefWalker extends RuleWalker { } this.addFailure(this.createFailure( node.getStart(), node.getWidth(), - `module-private member ${node.name.getText()} must be annotated @internal`)); + `module-private member ${node.name?.getText()} must be annotated @internal`)); } }