refactor(platform-browser): ensure compatibility with noImplicitOverride (#42512)

Adds the `override` keyword to the `platform-browser` sources to ensure
compatibility with `noImplicitOverride`.

PR Close #42512
This commit is contained in:
Paul Gschwendtner 2021-06-07 21:02:10 +02:00 committed by Andrew Kushnir
parent c74927da37
commit a2975c7507
6 changed files with 23 additions and 22 deletions

View File

@ -241,7 +241,7 @@ export class AnimationRenderer extends BaseAnimationRenderer implements Renderer
this.namespaceId = namespaceId;
}
setProperty(el: any, name: string, value: any): void {
override setProperty(el: any, name: string, value: any): void {
if (name.charAt(0) == ANIMATION_PREFIX) {
if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) {
value = value === undefined ? true : !!value;
@ -254,8 +254,9 @@ export class AnimationRenderer extends BaseAnimationRenderer implements Renderer
}
}
listen(target: 'window'|'document'|'body'|any, eventName: string, callback: (event: any) => any):
() => void {
override listen(
target: 'window'|'document'|'body'|any, eventName: string,
callback: (event: any) => any): () => void {
if (eventName.charAt(0) == ANIMATION_PREFIX) {
const element = resolveElementFromTarget(target);
let name = eventName.substr(1);

View File

@ -368,26 +368,26 @@ class MockAnimationEngine extends InjectableAnimationEngine {
data.push(args);
}
registerTrigger(
override registerTrigger(
componentId: string, namespaceId: string, hostElement: any, name: string,
metadata: AnimationTriggerMetadata): void {
this.triggers.push(metadata);
}
onInsert(namespaceId: string, element: any): void {
override onInsert(namespaceId: string, element: any): void {
this._capture('onInsert', [element]);
}
onRemove(namespaceId: string, element: any, domFn: () => any): void {
override onRemove(namespaceId: string, element: any, domFn: () => any): void {
this._capture('onRemove', [element]);
}
process(namespaceId: string, element: any, property: string, value: any): boolean {
override process(namespaceId: string, element: any, property: string, value: any): boolean {
this._capture('setProperty', [element, property, value]);
return true;
}
listen(
override listen(
namespaceId: string, element: any, eventName: string, eventPhase: string,
callback: (event: any) => any): () => void {
// we don't capture the callback here since the renderer wraps it in a zone
@ -395,21 +395,21 @@ class MockAnimationEngine extends InjectableAnimationEngine {
return () => {};
}
flush() {}
override flush() {}
destroy(namespaceId: string) {}
override destroy(namespaceId: string) {}
}
@Injectable()
class ExtendedAnimationRendererFactory extends AnimationRendererFactory {
public log: string[] = [];
begin() {
override begin() {
super.begin();
this.log.push('begin');
}
end() {
override end() {
super.end();
this.log.push('end');
}

View File

@ -304,7 +304,7 @@ class EmulatedEncapsulationDomRenderer2 extends DefaultDomRenderer2 {
super.setAttribute(element, this.hostAttr, '');
}
createElement(parent: any, name: string): Element {
override createElement(parent: any, name: string): Element {
const el = super.createElement(parent, name);
super.setAttribute(el, this.contentAttr, '');
return el;
@ -332,20 +332,20 @@ class ShadowDomRenderer extends DefaultDomRenderer2 {
return node === this.hostEl ? this.shadowRoot : node;
}
destroy() {
override destroy() {
this.sharedStylesHost.removeHost(this.shadowRoot);
}
appendChild(parent: any, newChild: any): void {
override appendChild(parent: any, newChild: any): void {
return super.appendChild(this.nodeOrShadowRoot(parent), newChild);
}
insertBefore(parent: any, newChild: any, refChild: any): void {
override insertBefore(parent: any, newChild: any, refChild: any): void {
return super.insertBefore(this.nodeOrShadowRoot(parent), newChild, refChild);
}
removeChild(parent: any, oldChild: any): void {
override removeChild(parent: any, oldChild: any): void {
return super.removeChild(this.nodeOrShadowRoot(parent), oldChild);
}
parentNode(node: any): any {
override parentNode(node: any): any {
return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(node)));
}
}

View File

@ -64,7 +64,7 @@ export class DomSharedStylesHost extends SharedStylesHost implements OnDestroy {
this._hostNodes.delete(hostNode);
}
onStylesAdded(additions: Set<string>): void {
override onStylesAdded(additions: Set<string>): void {
this._hostNodes.forEach((styleNodes, hostNode) => {
this._addStylesToHost(additions, hostNode, styleNodes);
});

View File

@ -526,10 +526,10 @@ class FakeNgZone extends NgZone {
constructor() {
super({enableLongStackTrace: false, shouldCoalesceEventChangeDetection: true});
}
run<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T {
override run<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T {
return fn();
}
runOutsideAngular(fn: Function) {
override runOutsideAngular(fn: Function) {
return fn();
}
}

View File

@ -70,7 +70,7 @@ class FancyService {
}
class MockFancyService extends FancyService {
value: string = 'mocked out value';
override value: string = 'mocked out value';
}
@Component({