Skip to content

Commit 177fc84

Browse files
Scheduler: fix ts issues in demos in strict mode (#32101)
Co-authored-by: EugeniyKiyashko <[email protected]>
1 parent 5d15a0f commit 177fc84

File tree

46 files changed

+132
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+132
-116
lines changed

apps/demos/Demos/Pagination/Overview/React/EmployeeCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Employee } from './data';
2+
import type { Employee } from './data';
33

44
interface EmployeeCardProps {
55
employee: Employee;

apps/demos/Demos/Pagination/Overview/React/EmployeesGallery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import EmployeeCard from './EmployeeCard.tsx';
3-
import { Employee } from './data';
3+
import type { Employee } from './data';
44

55
interface EmployeeGalleryProps {
66
employees: Employee[];

apps/demos/Demos/Scheduler/AllDayPanelMode/React/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { useCallback, useState } from 'react';
2-
import Scheduler, { type SchedulerTypes } from 'devextreme-react/scheduler';
3-
import RadioGroup, { type RadioGroupTypes } from 'devextreme-react/radio-group';
2+
import Scheduler from 'devextreme-react/scheduler';
3+
import RadioGroup from 'devextreme-react/radio-group';
4+
import type { SchedulerTypes } from 'devextreme-react/scheduler';
5+
import type { RadioGroupTypes } from 'devextreme-react/radio-group';
46
import { data } from './data.ts';
57

68
const currentDate = new Date(2021, 2, 28);

apps/demos/Demos/Scheduler/AppointmentCountPerCell/React/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
2-
import Scheduler, { Resource, type SchedulerTypes } from 'devextreme-react/scheduler';
2+
import Scheduler, { Resource } from 'devextreme-react/scheduler';
3+
import type { SchedulerTypes } from 'devextreme-react/scheduler';
34

45
import { data, resourcesData } from './data.ts';
56

apps/demos/Demos/Scheduler/BasicViews/React/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22

3-
import Scheduler, { type SchedulerTypes } from 'devextreme-react/scheduler';
3+
import Scheduler from 'devextreme-react/scheduler';
4+
import type { SchedulerTypes } from 'devextreme-react/scheduler';
45

56
import { data } from './data.ts';
67

apps/demos/Demos/Scheduler/CellTemplates/React/App.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const notifyDisableDate = () => {
3737
};
3838

3939
const onContentReady = (e: SchedulerTypes.ContentReadyEvent) => {
40-
setComponentAria(e.component?.$element());
40+
const element = e.component?.element();
41+
element && setComponentAria(element);
4142
};
4243

4344
const applyDisableDatesToDateEditors = (form: ReturnType<FormRef['instance']>) => {
@@ -75,11 +76,11 @@ const onAppointmentUpdating = (e: SchedulerTypes.AppointmentUpdatingEvent) => {
7576
}
7677
};
7778

78-
const setComponentAria = (element) => {
79-
const prevAria = element?.attr('aria-label') || '';
79+
const setComponentAria = (element: HTMLElement) => {
80+
const prevAria = element.getAttribute('aria-label') || '';
8081
const description = ariaDescription();
8182
const nextAria = `${prevAria}${description ? ` ${description}` : ''}`;
82-
element?.attr('aria-label', nextAria);
83+
element.setAttribute('aria-label', nextAria);
8384
};
8485

8586
const App = () => {

apps/demos/Demos/Scheduler/CellTemplates/React/DateCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { type SchedulerTypes } from 'devextreme-react/scheduler';
2+
import type { SchedulerTypes } from 'devextreme-react/scheduler';
33
import Utils from './utils.ts';
44

55
interface DateCellProps {

apps/demos/Demos/Scheduler/CellTemplates/React/TimeCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const TimeCell = (props: TimeCellProps) => {
1212
const hasCoffeeCupIcon = Utils.hasCoffeeCupIcon(date);
1313

1414
return (
15-
<div className={isDinner ? 'dinner' : null}>
15+
<div className={isDinner ? 'dinner' : undefined}>
1616
{text}
1717
{hasCoffeeCupIcon && <div className='cafe' />}
1818
</div>

apps/demos/Demos/Scheduler/CellTemplates/React/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export default class Utils {
2929
}
3030

3131
static isValidAppointment(component: SchedulerTypes.AppointmentAddingEvent['component'], appointmentData: SchedulerTypes.AppointmentAddingEvent['appointmentData']) {
32-
const startDate = new Date(appointmentData.startDate);
33-
const endDate = new Date(appointmentData.endDate);
34-
const cellDuration = component.option('cellDuration');
32+
const startDate = appointmentData.startDate ? new Date(appointmentData.startDate) : new Date();
33+
const endDate = appointmentData.endDate ? new Date(appointmentData.endDate) : new Date();
34+
const cellDuration = Number(component.option('cellDuration'));
3535
return Utils.isValidAppointmentInterval(startDate, endDate, cellDuration);
3636
}
3737

apps/demos/Demos/Scheduler/CellTemplates/ReactJs/App.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const notifyDisableDate = () => {
3737
);
3838
};
3939
const onContentReady = (e) => {
40-
setComponentAria(e.component?.$element());
40+
const element = e.component?.element();
41+
element && setComponentAria(element);
4142
};
4243
const applyDisableDatesToDateEditors = (form) => {
4344
const startDateEditor = form.getEditor('startDate');
@@ -70,10 +71,10 @@ const onAppointmentUpdating = (e) => {
7071
}
7172
};
7273
const setComponentAria = (element) => {
73-
const prevAria = element?.attr('aria-label') || '';
74+
const prevAria = element.getAttribute('aria-label') || '';
7475
const description = ariaDescription();
7576
const nextAria = `${prevAria}${description ? ` ${description}` : ''}`;
76-
element?.attr('aria-label', nextAria);
77+
element.setAttribute('aria-label', nextAria);
7778
};
7879
const App = () => {
7980
const [currentView, setCurrentView] = useState(views[0]);

0 commit comments

Comments
 (0)