Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

refactor: Add declare to class fields in child class that overrides a base class field without explicitly reinitializing the field. #8206

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/mdc-switch/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MDCSwitchAdapter> {
export class MDCSwitchFoundation extends MDCObserverFoundation<MDCSwitchAdapter> {
constructor(adapter: MDCSwitchAdapter) {
super(adapter);
this.handleClick = this.handleClick.bind(this);
Expand Down Expand Up @@ -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.
Expand All @@ -90,7 +89,7 @@ export class MDCSwitchRenderFoundation extends MDCSwitchFoundation {
disabled: this.onDisabledChange,
processing: this.onProcessingChange,
selected: this.onSelectedChange,
})
});
}

/**
Expand All @@ -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);
Expand Down
Loading