From 16b8e1a170126a5fa74de5d3eb08bb433723689b Mon Sep 17 00:00:00 2001 From: EugeniyKiyashko Date: Thu, 19 Nov 2026 10:02:49 +0400 Subject: [PATCH] Scheduler: extend the internal Widget, drop the type suppressions it makes unnecessary (#5348) --- .../js/__internal/scheduler/scheduler.ts | 36 ++++--------------- .../scheduler_options_base_widget.ts | 16 +++------ .../scheduler/utils/options/types.ts | 6 ++-- 3 files changed, 13 insertions(+), 45 deletions(-) diff --git a/packages/devextreme/js/__internal/scheduler/scheduler.ts b/packages/devextreme/js/__internal/scheduler/scheduler.ts index 026feb08e5a1..ef95f5991cb4 100644 --- a/packages/devextreme/js/__internal/scheduler/scheduler.ts +++ b/packages/devextreme/js/__internal/scheduler/scheduler.ts @@ -7,7 +7,6 @@ import type { DataSource } from '@js/common/data'; import registerComponent from '@js/core/component_registrator'; import config from '@js/core/config'; import { getPublicElement } from '@js/core/element'; -import type { PostponedOperations } from '@js/core/postponed_operations'; import type { Coordinates, dxElementWrapper } from '@js/core/renderer'; import $ from '@js/core/renderer'; import { BindableTemplate } from '@js/core/templates/bindable_template'; @@ -57,7 +56,6 @@ import type { SelectionEndEvent, } from '@js/ui/scheduler'; import errors from '@js/ui/widget/ui.errors'; -import type { Options } from '@ts/core/options/index'; import { addOffsets, isValidDate } from '@ts/core/utils/date'; import { tabbable } from '@ts/core/utils/selectors'; import type { OptionChanged } from '@ts/core/widget/types'; @@ -95,7 +93,6 @@ import type { AppointmentTooltipExtraOptions, AppointmentTooltipOptions } from ' import type { AppointmentTooltipContextMenuEventArgs, AppointmentTooltipItem, - CreateComponentFn, DOMMetaData, GroupBoundsOffset, MappedAppointmentFields, @@ -366,12 +363,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { // and initialization in constructor will erase the data private timeZoneCalculatorInstance: TimeZoneCalculator | null = null; - declare postponedOperations: PostponedOperations; - - declare _disposed?: boolean; - - declare _options: Options; - private a11yStatus!: dxElementWrapper; // TODO: used externally in m_appointment_drag_behavior.ts, @@ -388,9 +379,8 @@ class Scheduler extends SchedulerOptionsBaseWidget { declare _dataSource: DataSource | undefined; - // TODO: used externally in workspaces/work_space.ts // eslint-disable-next-line @typescript-eslint/naming-convention -- inherited Widget API - declare _createComponent: CreateComponentFn; + declare _getTemplate: (template: unknown) => FunctionTemplate; // TODO: used externally in m_subscribes.ts, // view_model/preparation/prepare_appointments.ts, @@ -679,7 +669,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { this.updateOption('header', name, value); this.updateOption('workSpace', name, value); this._appointments.option(name, value); - // @ts-expect-error super._optionChanged(args); break; case 'width': @@ -689,12 +678,10 @@ class Scheduler extends SchedulerOptionsBaseWidget { this.updateOption('workSpace', 'width', value); } this.updateOption('workSpace', 'schedulerWidth', value); - // @ts-expect-error super._optionChanged(args); this._dimensionChanged(null, true); break; case 'height': - // @ts-expect-error super._optionChanged(args); this._dimensionChanged(null, true); this.updateOption('workSpace', 'schedulerHeight', value); @@ -786,7 +773,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { } break; default: - // @ts-expect-error super._optionChanged(args); } } @@ -891,9 +877,9 @@ class Scheduler extends SchedulerOptionsBaseWidget { } _fireContentReadyAction(result?: DeferredObj): void { - // @ts-expect-error const contentReadyBase = super._fireContentReadyAction.bind(this); const fireContentReady = (): void => { + // eslint-disable-next-line @typescript-eslint/no-floating-promises contentReadyBase(); result?.resolve(); }; @@ -907,11 +893,10 @@ class Scheduler extends SchedulerOptionsBaseWidget { } } - _dimensionChanged(value: unknown, isForce = false): void { + _dimensionChanged(value?: unknown, isForce = false): void { const isFixedHeight = typeof this.option('height') === 'number'; const isFixedWidth = typeof this.option('width') === 'number'; - // @ts-expect-error if (!this._isVisible()) { return; } @@ -944,7 +929,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { _clean(): void { this.cleanPopup(); - // @ts-expect-error super._clean(); } @@ -1051,7 +1035,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { appointmentTooltip: new EmptyTemplate(), dropDownAppointment: new EmptyTemplate(), }); - // @ts-expect-error super._initTemplates(); } @@ -1100,7 +1083,7 @@ class Scheduler extends SchedulerOptionsBaseWidget { } _renderContent(): void { - // @ts-expect-error + // eslint-disable-next-line @typescript-eslint/no-floating-promises this._renderContentImpl(); } @@ -1132,7 +1115,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { workspace?.option('allDayExpanded', this.isAllDayExpanded()); - // @ts-expect-error const viewModel: AppointmentViewModelPlain[] = this._isVisible() ? this._layoutManager.generateViewModel() : []; @@ -1198,7 +1180,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { // NOTE: Stop all scheduled macro tasks macroTaskArray.dispose(); - // @ts-expect-error super._dispose(); } @@ -1248,7 +1229,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { indicatorTime, ); - // @ts-expect-error this.setAria({ label }); this.a11yStatus.text(label); } @@ -1256,7 +1236,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { private renderA11yStatus(): void { this.a11yStatus = createA11yStatusContainer(); this.a11yStatus.prependTo(this.$element()); - // @ts-expect-error this.setAria({ role: 'application' }); } @@ -1530,7 +1509,6 @@ class Scheduler extends SchedulerOptionsBaseWidget { _render(): void { this.getWorkSpace()?.updateHeaderEmptyCellWidth(); - // @ts-expect-error super._render(); } @@ -2713,10 +2691,8 @@ class Scheduler extends SchedulerOptionsBaseWidget { } } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -(Scheduler as any).include(DataHelperMixin); +Scheduler.include(DataHelperMixin); -// eslint-disable-next-line @typescript-eslint/no-explicit-any -registerComponent('dxScheduler', Scheduler as any); +registerComponent('dxScheduler', Scheduler); export default Scheduler; diff --git a/packages/devextreme/js/__internal/scheduler/scheduler_options_base_widget.ts b/packages/devextreme/js/__internal/scheduler/scheduler_options_base_widget.ts index 94b957f3f5f1..1145f7987b28 100644 --- a/packages/devextreme/js/__internal/scheduler/scheduler_options_base_widget.ts +++ b/packages/devextreme/js/__internal/scheduler/scheduler_options_base_widget.ts @@ -1,6 +1,6 @@ -import Widget from '@js/ui/widget/ui.widget'; import { extend } from '@ts/core/utils/extend'; import type { OptionChanged } from '@ts/core/widget/types'; +import Widget from '@ts/core/widget/widget'; import { DEFAULT_SCHEDULER_INTEGRATION_OPTIONS, @@ -18,8 +18,6 @@ import { SchedulerOptionsValidator, SchedulerOptionsValidatorErrorsHandler } fro import timeZoneUtils from './utils_time_zone'; export class SchedulerOptionsBaseWidget extends Widget { - declare _disposed?: boolean; - protected views: NormalizedView[] = []; public currentView!: NormalizedView; @@ -28,15 +26,13 @@ export class SchedulerOptionsBaseWidget extends Widget { private optionsValidatorErrorHandler!: SchedulerOptionsValidatorErrorsHandler; - protected _init(): void { - // @ts-expect-error + _init(): void { super._init(); this.optionsValidator = new SchedulerOptionsValidator(); this.optionsValidatorErrorHandler = new SchedulerOptionsValidatorErrorsHandler(); } - protected _getDefaultOptions(): SafeSchedulerOptions { - // @ts-expect-error + _getDefaultOptions(): SafeSchedulerOptions { const options = super._getDefaultOptions(); return extend(true, options, { @@ -46,8 +42,7 @@ export class SchedulerOptionsBaseWidget extends Widget { }) as SafeSchedulerOptions; } - protected _defaultOptionsRules(): SchedulerOptionsRule[] { - // @ts-expect-error + _defaultOptionsRules(): SchedulerOptionsRule[] { const rules: SchedulerOptionsRule[] = super._defaultOptionsRules(); return rules.concat(DEFAULT_SCHEDULER_OPTIONS_RULES); @@ -62,8 +57,7 @@ export class SchedulerOptionsBaseWidget extends Widget { ); } - protected _initMarkup(): void { - // @ts-expect-error + _initMarkup(): void { super._initMarkup(); this.updateViews(); this.validateOptions(); diff --git a/packages/devextreme/js/__internal/scheduler/utils/options/types.ts b/packages/devextreme/js/__internal/scheduler/utils/options/types.ts index c526fe3868bc..0fcad09a09ca 100644 --- a/packages/devextreme/js/__internal/scheduler/utils/options/types.ts +++ b/packages/devextreme/js/__internal/scheduler/utils/options/types.ts @@ -1,4 +1,5 @@ import type { template } from '@js/common'; +import type { DefaultOptionsRule } from '@js/core/options'; import type { Properties } from '@js/ui/scheduler'; export type RawViewType = Required['views'][number]; @@ -33,10 +34,7 @@ export interface SchedulerInternalOptions { skippedDays?: number[]; } -export interface SchedulerOptionsRule { - device: () => boolean; - options: Properties & Partial; -} +export type SchedulerOptionsRule = DefaultOptionsRule; type RequiredOptions = 'views' | 'currentView'