refactor(core): ensure compatibility with noImplicitOverride (#42512)

Adds the `override` keyword to the `core` sources to ensure
compatibility with `noImplicitOverride`.

PR Close #42512
This commit is contained in:
Paul Gschwendtner 2021-06-07 21:01:40 +02:00 committed by Andrew Kushnir
parent 73137563d5
commit c74927da37
21 changed files with 126 additions and 124 deletions

View File

@ -28,7 +28,7 @@ export interface ProviderLiteral {
export class ProvidersEvaluator extends StaticInterpreter { export class ProvidersEvaluator extends StaticInterpreter {
private _providerLiterals: ProviderLiteral[] = []; private _providerLiterals: ProviderLiteral[] = [];
visitObjectLiteralExpression(node: ts.ObjectLiteralExpression, context: any) { override visitObjectLiteralExpression(node: ts.ObjectLiteralExpression, context: any) {
const resolvedValue = const resolvedValue =
super.visitObjectLiteralExpression(node, {...context, insideProviderDef: true}); super.visitObjectLiteralExpression(node, {...context, insideProviderDef: true});
// do not collect nested object literals. e.g. a provider could use a // do not collect nested object literals. e.g. a provider could use a

View File

@ -32,7 +32,7 @@ export class TemplateUsageVisitor extends NullVisitor {
return !this.hasQueryTemplateReference && this.expressionAstVisitor.hasQueryPropertyRead; return !this.hasQueryTemplateReference && this.expressionAstVisitor.hasQueryPropertyRead;
} }
visitElement(element: Element): void { override visitElement(element: Element): void {
// In case there is a template references variable that matches the query property // In case there is a template references variable that matches the query property
// name, we can finish this visitor as such a template variable can be used in the // name, we can finish this visitor as such a template variable can be used in the
// entire template and the query therefore can't be accessed from the template. // entire template and the query therefore can't be accessed from the template.
@ -47,7 +47,7 @@ export class TemplateUsageVisitor extends NullVisitor {
visitAll(this, element.children); visitAll(this, element.children);
} }
visitTemplate(template: Template): void { override visitTemplate(template: Template): void {
visitAll(this, template.attributes); visitAll(this, template.attributes);
visitAll(this, template.inputs); visitAll(this, template.inputs);
visitAll(this, template.outputs); visitAll(this, template.outputs);
@ -57,15 +57,15 @@ export class TemplateUsageVisitor extends NullVisitor {
// lifecycle hook at the earliest. // lifecycle hook at the earliest.
} }
visitBoundAttribute(attribute: BoundAttribute) { override visitBoundAttribute(attribute: BoundAttribute) {
attribute.value.visit(this.expressionAstVisitor, attribute.sourceSpan); attribute.value.visit(this.expressionAstVisitor, attribute.sourceSpan);
} }
visitBoundText(text: BoundText) { override visitBoundText(text: BoundText) {
text.value.visit(this.expressionAstVisitor, text.sourceSpan); text.value.visit(this.expressionAstVisitor, text.sourceSpan);
} }
visitBoundEvent(node: BoundEvent) { override visitBoundEvent(node: BoundEvent) {
node.handler.visit(this.expressionAstVisitor, node.handlerSpan); node.handler.visit(this.expressionAstVisitor, node.handlerSpan);
} }
} }
@ -81,7 +81,7 @@ class ExpressionAstVisitor extends RecursiveAstVisitor {
super(); super();
} }
visitPropertyRead(node: PropertyRead, span: ParseSourceSpan): any { override visitPropertyRead(node: PropertyRead, span: ParseSourceSpan): any {
// The receiver of the property read needs to be "implicit" as queries are accessed // The receiver of the property read needs to be "implicit" as queries are accessed
// from the component instance and not from other objects. // from the component instance and not from other objects.
if (node.receiver instanceof ImplicitReceiver && node.name === this.queryPropertyName) { if (node.receiver instanceof ImplicitReceiver && node.name === this.queryPropertyName) {

View File

@ -26,12 +26,12 @@ export class HtmlVariableAssignmentVisitor extends NullVisitor {
private expressionAstVisitor = private expressionAstVisitor =
new ExpressionAstVisitor(this.variableAssignments, this.currentVariables); new ExpressionAstVisitor(this.variableAssignments, this.currentVariables);
visitElement(element: Element): void { override visitElement(element: Element): void {
visitAll(this, element.outputs); visitAll(this, element.outputs);
visitAll(this, element.children); visitAll(this, element.children);
} }
visitTemplate(template: Template): void { override visitTemplate(template: Template): void {
// Keep track of the template variables which can be accessed by the template // Keep track of the template variables which can be accessed by the template
// child nodes through the implicit receiver. // child nodes through the implicit receiver.
this.currentVariables.push(...template.variables); this.currentVariables.push(...template.variables);
@ -52,7 +52,7 @@ export class HtmlVariableAssignmentVisitor extends NullVisitor {
}); });
} }
visitBoundEvent(node: BoundEvent) { override visitBoundEvent(node: BoundEvent) {
node.handler.visit(this.expressionAstVisitor, node.handlerSpan); node.handler.visit(this.expressionAstVisitor, node.handlerSpan);
} }
} }
@ -65,7 +65,7 @@ class ExpressionAstVisitor extends RecursiveAstVisitor {
super(); super();
} }
visitPropertyWrite(node: PropertyWrite, span: ParseSourceSpan) { override visitPropertyWrite(node: PropertyWrite, span: ParseSourceSpan) {
if (node.receiver instanceof ImplicitReceiver && if (node.receiver instanceof ImplicitReceiver &&
this.currentVariables.some(v => v.name === node.name)) { this.currentVariables.some(v => v.name === node.name)) {
this.variableAssignments.push({ this.variableAssignments.push({

View File

@ -63,7 +63,9 @@ export interface CompilerFacade {
createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan; createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan;
FactoryTarget: typeof FactoryTarget; FactoryTarget: typeof FactoryTarget;
ResourceLoader: {new(): ResourceLoader}; // Note that we do not use `{new(): ResourceLoader}` here because
// the resource loader class is abstract and not constructable.
ResourceLoader: Function&{prototype: ResourceLoader};
} }
export interface CoreEnvironment { export interface CoreEnvironment {

View File

@ -114,7 +114,7 @@ class EventEmitter_ extends Subject<any> {
super.next(value); super.next(value);
} }
subscribe(observerOrNext?: any, error?: any, complete?: any): Subscription { override subscribe(observerOrNext?: any, error?: any, complete?: any): Subscription {
let nextFn = observerOrNext; let nextFn = observerOrNext;
let errorFn = error || (() => null); let errorFn = error || (() => null);
let completeFn = complete; let completeFn = complete;

View File

@ -308,15 +308,15 @@ export class RootViewRef<T> extends ViewRef<T> {
super(_view); super(_view);
} }
detectChanges(): void { override detectChanges(): void {
detectChangesInRootView(this._view); detectChangesInRootView(this._view);
} }
checkNoChanges(): void { override checkNoChanges(): void {
checkNoChangesInRootView(this._view); checkNoChangesInRootView(this._view);
} }
get context(): T { override get context(): T {
return null!; return null!;
} }
} }

View File

@ -1189,7 +1189,7 @@ describe('change detection', () => {
// Custom error handler that just rethrows all the errors from the // Custom error handler that just rethrows all the errors from the
// view, rather than logging them out. Used to keep our logs clean. // view, rather than logging them out. Used to keep our logs clean.
class RethrowErrorHandler extends ErrorHandler { class RethrowErrorHandler extends ErrorHandler {
handleError(error: any) { override handleError(error: any) {
throw error; throw error;
} }
} }

View File

@ -54,11 +54,11 @@ describe('change detection for transplanted views', () => {
template: insertCompTemplate, template: insertCompTemplate,
}) })
class InsertForOnPushDeclareComp extends InsertComp { class InsertForOnPushDeclareComp extends InsertComp {
constructor(public changeDetectorRef: ChangeDetectorRef) { constructor(changeDetectorRef: ChangeDetectorRef) {
super(changeDetectorRef); super(changeDetectorRef);
insertForOnPushDeclareComp = this; insertForOnPushDeclareComp = this;
} }
get template(): TemplateRef<any> { override get template(): TemplateRef<any> {
return onPushDeclareComp.myTmpl; return onPushDeclareComp.myTmpl;
} }
} }
@ -105,7 +105,7 @@ describe('change detection for transplanted views', () => {
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
class OnPushDeclareComp extends DeclareComp { class OnPushDeclareComp extends DeclareComp {
constructor(readonly changeDetector: ChangeDetectorRef) { constructor(changeDetector: ChangeDetectorRef) {
super(changeDetector); super(changeDetector);
onPushDeclareComp = this; onPushDeclareComp = this;
} }

View File

@ -40,7 +40,7 @@ describe('Ivy CopyDefinitionFeature', () => {
} }
class ChildComponent extends BaseComponent { class ChildComponent extends BaseComponent {
static ɵcmp = defineComponent({ static override ɵcmp = defineComponent({
type: ChildComponent, type: ChildComponent,
selectors: [['some-cmp']], selectors: [['some-cmp']],
features: [InheritDefinitionFeature, CopyDefinitionFeature], features: [InheritDefinitionFeature, CopyDefinitionFeature],
@ -49,7 +49,7 @@ describe('Ivy CopyDefinitionFeature', () => {
template: function ChildComponent_Template(rf, ctx) {}, template: function ChildComponent_Template(rf, ctx) {},
encapsulation: 2 encapsulation: 2
}); });
static ɵfac = function ChildComponent_Factory(t: any) { static override ɵfac = function ChildComponent_Factory(t: any) {
return new (t || ChildComponent)(); return new (t || ChildComponent)();
}; };
} }

View File

@ -2040,7 +2040,7 @@ describe('di', () => {
} }
class MyRootService extends MyService { class MyRootService extends MyService {
id = 2; override id = 2;
} }
@Component({template: ''}) @Component({template: ''})

View File

@ -321,7 +321,7 @@ describe('inheritance', () => {
} }
abstract class UndecoratedBase extends Base { abstract class UndecoratedBase extends Base {
abstract input: any; abstract override input: any;
ngOnChanges() { ngOnChanges() {
changes++; changes++;
} }
@ -383,7 +383,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -424,7 +424,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -465,7 +465,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -506,7 +506,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -547,7 +547,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -588,7 +588,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -629,7 +629,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -684,7 +684,7 @@ describe('inheritance', () => {
selector: '[sub-dir]', selector: '[sub-dir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -943,7 +943,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -984,7 +984,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -1025,7 +1025,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -1066,7 +1066,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -1107,7 +1107,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -1148,7 +1148,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -1189,7 +1189,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -1245,7 +1245,7 @@ describe('inheritance', () => {
selector: '[sub-dir]', selector: '[sub-dir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -1513,7 +1513,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -1554,7 +1554,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -1595,7 +1595,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -1636,7 +1636,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -1677,7 +1677,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -1718,7 +1718,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -1759,7 +1759,7 @@ describe('inheritance', () => {
selector: '[subDir]', selector: '[subDir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -1817,7 +1817,7 @@ describe('inheritance', () => {
selector: '[sub-dir]', selector: '[sub-dir]',
}) })
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -2118,7 +2118,7 @@ describe('inheritance', () => {
it('ngOnInit', () => { it('ngOnInit', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -2159,7 +2159,7 @@ describe('inheritance', () => {
selector: 'my-comp', selector: 'my-comp',
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -2201,7 +2201,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -2243,7 +2243,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -2285,7 +2285,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -2327,7 +2327,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -2369,7 +2369,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -2422,7 +2422,7 @@ describe('inheritance', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -2675,7 +2675,7 @@ describe('inheritance', () => {
it('ngOnInit', () => { it('ngOnInit', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -2717,7 +2717,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -2759,7 +2759,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -2801,7 +2801,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -2843,7 +2843,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -2885,7 +2885,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -2927,7 +2927,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -2983,7 +2983,7 @@ describe('inheritance', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends SuperDirective { class MyComponent extends SuperDirective {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -3296,7 +3296,7 @@ describe('inheritance', () => {
it('ngOnInit', () => { it('ngOnInit', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends BareClass { class MyComponent extends BareClass {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -3337,7 +3337,7 @@ describe('inheritance', () => {
selector: 'my-comp', selector: 'my-comp',
}) })
class MyComponent extends BareClass { class MyComponent extends BareClass {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -3379,7 +3379,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends BareClass { class MyComponent extends BareClass {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -3421,7 +3421,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends BareClass { class MyComponent extends BareClass {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -3463,7 +3463,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends BareClass { class MyComponent extends BareClass {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -3505,7 +3505,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends BareClass { class MyComponent extends BareClass {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -3547,7 +3547,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends BareClass { class MyComponent extends BareClass {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -3605,7 +3605,7 @@ describe('inheritance', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends BareClass { class MyComponent extends BareClass {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -3941,7 +3941,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -3983,7 +3983,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -4025,7 +4025,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -4067,7 +4067,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -4109,7 +4109,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -4151,7 +4151,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -4193,7 +4193,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -4250,7 +4250,7 @@ describe('inheritance', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -4623,7 +4623,7 @@ describe('inheritance', () => {
focused() { focused() {
} }
clicked() { override clicked() {
events.push('ChildComponent.clicked'); events.push('ChildComponent.clicked');
} }
} }
@ -4640,7 +4640,7 @@ describe('inheritance', () => {
blurred() { blurred() {
} }
clicked() { override clicked() {
events.push('GrandChildComponent.clicked'); events.push('GrandChildComponent.clicked');
} }
} }
@ -4741,7 +4741,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngOnInit() { override ngOnInit() {
fired.push('sub init'); fired.push('sub init');
} }
} }
@ -4783,7 +4783,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngDoCheck() { override ngDoCheck() {
fired.push('sub do check'); fired.push('sub do check');
} }
} }
@ -4825,7 +4825,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterContentInit() { override ngAfterContentInit() {
fired.push('sub after content init'); fired.push('sub after content init');
} }
} }
@ -4867,7 +4867,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterContentChecked() { override ngAfterContentChecked() {
fired.push('sub after content checked'); fired.push('sub after content checked');
} }
} }
@ -4909,7 +4909,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterViewInit() { override ngAfterViewInit() {
fired.push('sub after view init'); fired.push('sub after view init');
} }
} }
@ -4951,7 +4951,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngAfterViewChecked() { override ngAfterViewChecked() {
fired.push('sub after view checked'); fired.push('sub after view checked');
} }
} }
@ -4993,7 +4993,7 @@ describe('inheritance', () => {
template: `<p>test</p>`, template: `<p>test</p>`,
}) })
class MyComponent extends SuperComponent { class MyComponent extends SuperComponent {
ngOnDestroy() { override ngOnDestroy() {
fired.push('sub destroy'); fired.push('sub destroy');
} }
} }
@ -5052,7 +5052,7 @@ describe('inheritance', () => {
@Component({selector: 'my-comp', template: `<p>test</p>`}) @Component({selector: 'my-comp', template: `<p>test</p>`})
class MyComponent extends BareClass { class MyComponent extends BareClass {
@Input() baz = ''; @Input() override baz = '';
@Input() qux = ''; @Input() qux = '';
} }
@ -5182,8 +5182,8 @@ describe('inheritance', () => {
], ],
}) })
class MyComponent extends IntermediateComponent { class MyComponent extends IntermediateComponent {
colorExp = 'color'; override colorExp = 'color';
opacityExp = 'opacity'; override opacityExp = 'opacity';
bgExp = 'bg'; bgExp = 'bg';
} }

View File

@ -1253,17 +1253,17 @@ it('should call all hooks in correct order when several directives on same node'
@Directive({selector: 'div'}) @Directive({selector: 'div'})
class DirA extends AllHooks { class DirA extends AllHooks {
@Input('a') id: number = 0; @Input('a') override id: number = 0;
} }
@Directive({selector: 'div'}) @Directive({selector: 'div'})
class DirB extends AllHooks { class DirB extends AllHooks {
@Input('b') id: number = 0; @Input('b') override id: number = 0;
} }
@Directive({selector: 'div'}) @Directive({selector: 'div'})
class DirC extends AllHooks { class DirC extends AllHooks {
@Input('c') id: number = 0; @Input('c') override id: number = 0;
} }
@Component({selector: 'app-comp', template: '<div [a]="1" [b]="2" [c]="3"></div>'}) @Component({selector: 'app-comp', template: '<div [a]="1" [b]="2" [c]="3"></div>'})

View File

@ -155,7 +155,7 @@ describe('event listeners', () => {
let noOfErrors = 0; let noOfErrors = 0;
class CountingErrorHandler extends ErrorHandler { class CountingErrorHandler extends ErrorHandler {
handleError(error: any): void { override handleError(error: any): void {
noOfErrors++; noOfErrors++;
} }
} }

View File

@ -33,7 +33,7 @@ class Dashboard {
} }
class TurboEngine extends Engine { class TurboEngine extends Engine {
static PROVIDER = {provide: Engine, useClass: TurboEngine, deps: []}; static override PROVIDER = {provide: Engine, useClass: TurboEngine, deps: []};
} }
class Car { class Car {
@ -65,7 +65,7 @@ class CarWithDashboard {
} }
class SportsCar extends Car { class SportsCar extends Car {
static PROVIDER = {provide: Car, useClass: SportsCar, deps: [Engine]}; static override PROVIDER = {provide: Car, useClass: SportsCar, deps: [Engine]};
} }
class CyclicEngine { class CyclicEngine {

View File

@ -477,7 +477,7 @@ describe('jit source mapping', () => {
class MockJitEvaluator extends JitEvaluator { class MockJitEvaluator extends JitEvaluator {
sources: string[] = []; sources: string[] = [];
executeFunction(fn: Function, args: any[]) { override executeFunction(fn: Function, args: any[]) {
// Capture the source that has been generated. // Capture the source that has been generated.
this.sources.push(fn.toString()); this.sources.push(fn.toString());
// Then execute it anyway. // Then execute it anyway.

View File

@ -423,7 +423,7 @@ class TestObj {
class Child extends Parent { class Child extends Parent {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@PropDecorator('b2') b!: B; @PropDecorator('b2') override b!: B;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@PropDecorator('c') c!: C; @PropDecorator('c') c!: C;
} }
@ -455,7 +455,7 @@ class TestObj {
} }
class Child extends Parent { class Child extends Parent {
hook2() {} override hook2() {}
hook3() {} hook3() {}
} }
@ -477,7 +477,7 @@ class TestObj {
} }
class Child extends Parent { class Child extends Parent {
static decorators = [{type: ClassDecorator, args: [{value: 'child'}]}]; static override decorators = [{type: ClassDecorator, args: [{value: 'child'}]}];
} }
class ChildNoDecorators extends Parent {} class ChildNoDecorators extends Parent {}
@ -508,7 +508,7 @@ class TestObj {
class Child extends Parent {} class Child extends Parent {}
class ChildWithCtor extends Parent { class ChildWithCtor extends Parent {
static ctorParameters = () => static override ctorParameters = () =>
[{type: C, decorators: [{type: ParamDecorator, args: ['c']}]}, [{type: C, decorators: [{type: ParamDecorator, args: ['c']}]},
] ]
constructor() { constructor() {
@ -541,7 +541,7 @@ class TestObj {
} }
class Child extends Parent { class Child extends Parent {
static propDecorators: any = { static override propDecorators: any = {
'b': [{type: PropDecorator, args: ['b2']}], 'b': [{type: PropDecorator, args: ['b2']}],
'c': [{type: PropDecorator, args: ['c']}], 'c': [{type: PropDecorator, args: ['c']}],
}; };
@ -568,7 +568,7 @@ class TestObj {
} }
class Child extends Parent { class Child extends Parent {
static annotations = [new ClassDecorator({value: 'child'})]; static override annotations = [new ClassDecorator({value: 'child'})];
} }
class ChildNoDecorators extends Parent {} class ChildNoDecorators extends Parent {}
@ -599,7 +599,7 @@ class TestObj {
class Child extends Parent {} class Child extends Parent {}
class ChildWithCtor extends Parent { class ChildWithCtor extends Parent {
static parameters = [ static override parameters = [
[C, new ParamDecorator('c')], [C, new ParamDecorator('c')],
]; ];
constructor() { constructor() {
@ -632,7 +632,7 @@ class TestObj {
} }
class Child extends Parent { class Child extends Parent {
static propMetadata: any = { static override propMetadata: any = {
'b': [new PropDecorator('b2')], 'b': [new PropDecorator('b2')],
'c': [new PropDecorator('c')], 'c': [new PropDecorator('c')],
}; };

View File

@ -52,7 +52,7 @@ class DependingClass {
} }
class ChildClass extends DependingClass { class ChildClass extends DependingClass {
static ɵfac = static override ɵfac =
ɵɵngDeclareFactory({type: ChildClass, deps: null, target: ɵɵFactoryTarget.Injectable}); ɵɵngDeclareFactory({type: ChildClass, deps: null, target: ɵɵFactoryTarget.Injectable});
} }

View File

@ -107,7 +107,7 @@ describe('pipe', () => {
transform() { transform() {
return this.sayHelloService.getHello(); return this.sayHelloService.getHello();
} }
static ɵfac = (t?: any) => ɵɵgetInheritedFactory(t || SayHelloPipe)(SayHelloPipe); static override ɵfac = (t?: any) => ɵɵgetInheritedFactory(t || SayHelloPipe)(SayHelloPipe);
static ɵpipe = ɵɵdefinePipe({name: 'sayHello', type: SayHelloPipe, pure: true}); static ɵpipe = ɵɵdefinePipe({name: 'sayHello', type: SayHelloPipe, pure: true});
} }

View File

@ -1293,11 +1293,11 @@ describe('providers', () => {
@addFoo() @addFoo()
class Parent extends GrandParent { class Parent extends GrandParent {
static ɵfac = function Parent_Factory() {}; static override ɵfac = function Parent_Factory() {};
} }
class Child extends Parent { class Child extends Parent {
static ɵfac = function Child_Factory() {}; static override ɵfac = function Child_Factory() {};
} }
expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory'); expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory');
@ -1311,12 +1311,12 @@ describe('providers', () => {
} }
class Parent extends GrandParent { class Parent extends GrandParent {
static ɵfac = function Parent_Factory() {}; static override ɵfac = function Parent_Factory() {};
} }
@addFoo() @addFoo()
class Child extends Parent { class Child extends Parent {
static ɵfac = function Child_Factory() {}; static override ɵfac = function Child_Factory() {};
} }
expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory'); expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory');
@ -1331,11 +1331,11 @@ describe('providers', () => {
} }
class Parent extends GrandParent { class Parent extends GrandParent {
static ɵfac = function Parent_Factory() {}; static override ɵfac = function Parent_Factory() {};
} }
class Child extends Parent { class Child extends Parent {
static ɵfac = function Child_Factory() {}; static override ɵfac = function Child_Factory() {};
} }
expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory'); expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory');
@ -1351,12 +1351,12 @@ describe('providers', () => {
@addFoo() @addFoo()
class Parent extends GrandParent { class Parent extends GrandParent {
static ɵfac = function Parent_Factory() {}; static override ɵfac = function Parent_Factory() {};
} }
@addFoo() @addFoo()
class Child extends Parent { class Child extends Parent {
static ɵfac = function Child_Factory() {}; static override ɵfac = function Child_Factory() {};
} }
expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory'); expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory');
@ -1373,11 +1373,11 @@ describe('providers', () => {
@addFoo() @addFoo()
class Parent extends GrandParent { class Parent extends GrandParent {
static ɵfac = function Parent_Factory() {}; static override ɵfac = function Parent_Factory() {};
} }
class Child extends Parent { class Child extends Parent {
static ɵfac = function Child_Factory() {}; static override ɵfac = function Child_Factory() {};
} }
expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory'); expect(ɵɵgetInheritedFactory(Child).name).toBe('Parent_Factory');

View File

@ -26,10 +26,10 @@ function microTask(fn: Function): void {
@Injectable() @Injectable()
class MockNgZone extends NgZone { class MockNgZone extends NgZone {
/** @internal */ /** @internal */
onUnstable: EventEmitter<any>; override onUnstable: EventEmitter<any>;
/** @internal */ /** @internal */
onStable: EventEmitter<any>; override onStable: EventEmitter<any>;
constructor() { constructor() {
super({enableLongStackTrace: false}); super({enableLongStackTrace: false});

View File

@ -14,17 +14,17 @@ import {EventEmitter, Injectable, NgZone} from '@angular/core';
*/ */
@Injectable() @Injectable()
export class MockNgZone extends NgZone { export class MockNgZone extends NgZone {
onStable: EventEmitter<any> = new EventEmitter(false); override onStable: EventEmitter<any> = new EventEmitter(false);
constructor() { constructor() {
super({enableLongStackTrace: false, shouldCoalesceEventChangeDetection: false}); super({enableLongStackTrace: false, shouldCoalesceEventChangeDetection: false});
} }
run(fn: Function): any { override run(fn: Function): any {
return fn(); return fn();
} }
runOutsideAngular(fn: Function): any { override runOutsideAngular(fn: Function): any {
return fn(); return fn();
} }