From 8948c93024e178a766466365f27997d00c25bf32 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 7 Jun 2021 21:03:01 +0200 Subject: [PATCH] refactor(platform-server): ensure compatibility with noImplicitOverride (#42512) Adds the `override` keyword to the `platform-server` sources to ensure compatibility with `noImplicitOverride`. PR Close #42512 --- .../platform-server/src/domino_adapter.ts | 22 +++++++++---------- .../platform-server/src/server_renderer.ts | 2 +- packages/platform-server/src/styles_host.ts | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/platform-server/src/domino_adapter.ts b/packages/platform-server/src/domino_adapter.ts index b844231f27..f0df4b324a 100644 --- a/packages/platform-server/src/domino_adapter.ts +++ b/packages/platform-server/src/domino_adapter.ts @@ -36,34 +36,34 @@ export function serializeDocument(doc: Document): string { * DOM Adapter for the server platform based on https://github.com/fgnass/domino. */ export class DominoAdapter extends BrowserDomAdapter { - static makeCurrent() { + static override makeCurrent() { setDomTypes(); setRootDomAdapter(new DominoAdapter()); } - readonly supportsDOMEvents = false; + override readonly supportsDOMEvents = false; private static defaultDoc: Document; - createHtmlDocument(): HTMLDocument { + override createHtmlDocument(): HTMLDocument { return parseDocument('fakeTitle'); } - getDefaultDocument(): Document { + override getDefaultDocument(): Document { if (!DominoAdapter.defaultDoc) { DominoAdapter.defaultDoc = domino.createDocument(); } return DominoAdapter.defaultDoc; } - isElementNode(node: any): boolean { + override isElementNode(node: any): boolean { return node ? node.nodeType === DominoAdapter.defaultDoc.ELEMENT_NODE : false; } - isShadowRoot(node: any): boolean { + override isShadowRoot(node: any): boolean { return node.shadowRoot == node; } /** @deprecated No longer being used in Ivy code. To be removed in version 14. */ - getGlobalEventTarget(doc: Document, target: string): EventTarget|null { + override getGlobalEventTarget(doc: Document, target: string): EventTarget|null { if (target === 'window') { return doc.defaultView; } @@ -76,12 +76,12 @@ export class DominoAdapter extends BrowserDomAdapter { return null; } - getBaseHref(doc: Document): string { + override getBaseHref(doc: Document): string { // TODO(alxhub): Need relative path logic from BrowserDomAdapter here? return doc.documentElement!.querySelector('base')?.getAttribute('href') || ''; } - dispatchEvent(el: Node, evt: any) { + override dispatchEvent(el: Node, evt: any) { el.dispatchEvent(evt); // Dispatch the event to the window also. @@ -92,11 +92,11 @@ export class DominoAdapter extends BrowserDomAdapter { } } - getUserAgent(): string { + override getUserAgent(): string { return 'Fake user agent'; } - getCookie(name: string): string { + override getCookie(name: string): string { throw new Error('getCookie has not been implemented'); } } diff --git a/packages/platform-server/src/server_renderer.ts b/packages/platform-server/src/server_renderer.ts index 33f21fa4ab..c24b8a426a 100644 --- a/packages/platform-server/src/server_renderer.ts +++ b/packages/platform-server/src/server_renderer.ts @@ -267,7 +267,7 @@ class EmulatedEncapsulationServerRenderer2 extends DefaultServerRenderer2 { super.setAttribute(element, this.hostAttr, ''); } - createElement(parent: any, name: string): Element { + override createElement(parent: any, name: string): Element { const el = super.createElement(parent, name, this.document); super.setAttribute(el, this.contentAttr, ''); return el; diff --git a/packages/platform-server/src/styles_host.ts b/packages/platform-server/src/styles_host.ts index e8364cb183..3461c8f5e2 100644 --- a/packages/platform-server/src/styles_host.ts +++ b/packages/platform-server/src/styles_host.ts @@ -33,7 +33,7 @@ export class ServerStylesHost extends SharedStylesHost { this._styleNodes.add(el); } - onStylesAdded(additions: Set) { + override onStylesAdded(additions: Set) { additions.forEach(style => this._addStyle(style)); }