Scheduler: refactor workspaces module (TS): part 1#33824
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sergei Burkatskii <sergei.burkatskii@devexpress.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sergei Burkatskii <sergei.burkatskii@devexpress.com>
There was a problem hiding this comment.
Pull request overview
This PR continues the Scheduler workspace TypeScript refactor by tightening typings across workspace implementations (base workspace, month/week/day, timeline variants, agenda) and aligning option/change handling with internal “safe” scheduler option types.
Changes:
- Introduced and exported shared workspace typing primitives (scrollable config types, date generation options, option-changed option union) and applied stricter method signatures/return types.
- Switched workspace option typing from
dxSchedulerOptionsto internalSafeSchedulerOptions, and updated_optionChangedsignatures to use typedOptionChanged<...>. - Added
skippedDays?: number[]to internal scheduler options and propagated related typing usage through render option generation.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts | Adds exported workspace TS types, switches to SafeSchedulerOptions, tightens scrollable config and option-changed typing. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_week.ts | Adds explicit return types for overrides and tightens startDate typing. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_month.ts | Adds explicit method signatures, refines interval math typing, and exports month date-generation option typing usage. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_indicator.ts | Tightens types around the current-time indicator and option-changed handling. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_work_space_day.ts | Adds explicit return types for overrides and render method. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline.ts | Tightens typing for timeline workspace, scroll configs, and render option generation. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_week.ts | Adds explicit return types for overrides and registration typing suppression. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_month.ts | Tightens typing for header templates, start date calculation, and render option generation. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_timeline_day.ts | Adds explicit return types for overrides and registration typing suppression. |
| packages/devextreme/js/__internal/scheduler/workspaces/m_agenda.ts | Tightens Agenda workspace typing, improves some guards, and refactors several helpers to typed implementations. |
| packages/devextreme/js/__internal/scheduler/utils/options/types.ts | Adds skippedDays?: number[] to SchedulerInternalOptions. |
| packages/devextreme/js/__internal/scheduler/m_scheduler.ts | Types _optionChanged as OptionChanged<SafeSchedulerOptions>. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts:241
WorkspaceOptionsInternal.startDateis typed asDate, but Scheduler viewstartDateoption is declared asDate | number | string | undefined(seejs/ui/scheduler.d.ts:1161) and workspace default options setstartDate: null. This narrowing can hide invalid runtime values and makes downstream code assumeDatewhen it may benumber|string|null.
export type WorkspaceOptionsInternal = Omit<SafeSchedulerOptions, 'groups'> & {
groups: ResourceLoader[];
getResourceManager: () => ResourceManager;
startDate?: Date;
currentDate: Date;
intervalCount: number;
| { | ||
| dateTableCellsMeta: [[{}]], | ||
| allDayPanelCellsMeta: [{}], | ||
| dateTableCellsMeta: [[{ |
There was a problem hiding this comment.
Agenda does not have any "cells", those values just mocked and does not affect anything, but for type safety reasons I changed the mocked values, because dateTableCellsMeta is array of Rect. So I just pass empty rects.
…erScrollableConfig
| ); | ||
|
|
||
| const cellTemplate: any = this.option('resourceCellTemplate'); | ||
| const cellTemplate = this.option('resourceCellTemplate') as TemplateBase | undefined; |
There was a problem hiding this comment.
is it possible to remove this as by moving the type to the options type?
There was a problem hiding this comment.
Moved resourceCellTemplate to workspace internal options
| getAgendaVerticalStepHeight() { | ||
| return this.option('rowHeight'); | ||
| getAgendaVerticalStepHeight(): number { | ||
| return this.option('rowHeight') as number; |
There was a problem hiding this comment.
is it possible to remove as by moving rowHeight option to the options type?
There was a problem hiding this comment.
Moved rowHeight to workspace internal options
| this.option('endDayHour') as any, | ||
| this.option('agendaDuration') as any, | ||
| this.option('endDayHour'), | ||
| this.option('agendaDuration') as number, |
There was a problem hiding this comment.
is it possible to remove as by moving agendaDuration option to the options type?
There was a problem hiding this comment.
Moved agendaDuration to workspace internal options
| type?: ViewType; | ||
| }; | ||
|
|
||
| export type WorkspaceOptionChangedOptions = WorkspaceOptionsInternal & { |
There was a problem hiding this comment.
Why do we need both WorkspaceOptionsInternal and WorkspaceOptionChangedOptions? Why not use a single type for workspace options?
There was a problem hiding this comment.
Yes, you're right. Removed WorkspaceOptionChangedOptions. Also moved all missing options from m_scheduler workspace config to workspace internal options.
No description provided.