From 271ca163b6d47cf66135eea4b16c9e3aa4b7018c Mon Sep 17 00:00:00 2001 From: Material Web Team Date: Wed, 25 Sep 2024 23:50:48 -0700 Subject: [PATCH] refactor: Add `declare` to class fields in child class that overrides a base class field without explicitly reinitializing the field. PiperOrigin-RevId: 679013309 --- packages/mdc-switch/foundation.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/mdc-switch/foundation.ts b/packages/mdc-switch/foundation.ts index ed3f9531fce..00027a35c78 100644 --- a/packages/mdc-switch/foundation.ts +++ b/packages/mdc-switch/foundation.ts @@ -33,8 +33,7 @@ import {CssClasses} from './constants'; * State observers and event handler entrypoints update a component's adapter's * state with the logic needed for switch to function. */ -export class MDCSwitchFoundation extends - MDCObserverFoundation { +export class MDCSwitchFoundation extends MDCObserverFoundation { constructor(adapter: MDCSwitchAdapter) { super(adapter); this.handleClick = this.handleClick.bind(this); @@ -79,7 +78,7 @@ export class MDCSwitchFoundation extends * render adapter to keep the component's DOM updated with the state. */ export class MDCSwitchRenderFoundation extends MDCSwitchFoundation { - protected override adapter!: MDCSwitchRenderAdapter; + protected declare adapter: MDCSwitchRenderAdapter; /** * Initializes the foundation and starts observing state changes. @@ -90,7 +89,7 @@ export class MDCSwitchRenderFoundation extends MDCSwitchFoundation { disabled: this.onDisabledChange, processing: this.onProcessingChange, selected: this.onSelectedChange, - }) + }); } /** @@ -107,8 +106,9 @@ export class MDCSwitchRenderFoundation extends MDCSwitchFoundation { // Ensure aria-checked is set if attribute is not present this.onSelectedChange(); this.adapter.state.disabled = this.adapter.isDisabled(); - this.adapter.state.processing = - this.adapter.hasClass(CssClasses.PROCESSING); + this.adapter.state.processing = this.adapter.hasClass( + CssClasses.PROCESSING, + ); // Re-observe state this.setObserversEnabled(this.adapter.state, true);