Skip to content

Commit cce6684

Browse files
DataGrid: fix ts issues in demos in strict mode (25_2) (#32049)
1 parent 625323b commit cce6684

File tree

78 files changed

+482
-375
lines changed

Some content is hidden

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

78 files changed

+482
-375
lines changed

apps/demos/Demos/CardView/ColumnChooser/React/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const App = () => {
8686
keyExpr="ID"
8787
cardsPerRow="auto"
8888
cardMinWidth={300}
89-
allowColumnReordering={allowColumnReordering}
89+
allowColumnReordering={!!allowColumnReordering}
9090
>
9191
<SearchPanel
9292
visible={true}
@@ -97,11 +97,11 @@ const App = () => {
9797
height="340px"
9898
>
9999
<ColumnChooserSearch
100-
enabled={searchEnabled}
100+
enabled={!!searchEnabled}
101101
/>
102102
<ColumnChooserSelection
103-
allowSelectAll={allowSelectAll}
104-
selectByClick={selectByClick}
103+
allowSelectAll={!!allowSelectAll}
104+
selectByClick={!!selectByClick}
105105
/>
106106
</ColumnChooser>
107107
<CardCover

apps/demos/Demos/CardView/ColumnChooser/ReactJs/App.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,18 @@ const App = () => {
7979
keyExpr="ID"
8080
cardsPerRow="auto"
8181
cardMinWidth={300}
82-
allowColumnReordering={allowColumnReordering}
82+
allowColumnReordering={!!allowColumnReordering}
8383
>
8484
<SearchPanel visible={true} />
8585
<ColumnChooser
8686
enabled={true}
8787
mode={columnChooserMode}
8888
height="340px"
8989
>
90-
<ColumnChooserSearch enabled={searchEnabled} />
90+
<ColumnChooserSearch enabled={!!searchEnabled} />
9191
<ColumnChooserSelection
92-
allowSelectAll={allowSelectAll}
93-
selectByClick={selectByClick}
92+
allowSelectAll={!!allowSelectAll}
93+
selectByClick={!!selectByClick}
9494
/>
9595
</ColumnChooser>
9696
<CardCover

apps/demos/Demos/CardView/Selection/React/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const App = () => {
9797
<Selection
9898
mode={selectionMode}
9999
showCheckBoxesMode={showCheckBoxesMode}
100-
allowSelectAll={allowSelectAll}
100+
allowSelectAll={!!allowSelectAll}
101101
selectAllMode={selectAllMode}
102102
/>
103103
<Column

apps/demos/Demos/CardView/Selection/ReactJs/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const App = () => {
8282
<Selection
8383
mode={selectionMode}
8484
showCheckBoxesMode={showCheckBoxesMode}
85-
allowSelectAll={allowSelectAll}
85+
allowSelectAll={!!allowSelectAll}
8686
selectAllMode={selectAllMode}
8787
/>
8888
<Column dataField="FullName" />
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { type Vehicle } from './types';
3-
import { type DataGridTypes } from 'devextreme-react/data-grid';
3+
import type { DataGridTypes } from 'devextreme-react/data-grid';
44

55
export default function Category(props: DataGridTypes.ColumnCellTemplateData<Vehicle>) {
6-
return <div className="category__wrapper">{props.data.CategoryName}</div>;
6+
return <div className="category__wrapper">{props.data?.CategoryName}</div>;
77
}

apps/demos/Demos/DataGrid/AIColumns/React/service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ async function getAIResponse(messages: AIMessage[], signal: AbortSignal) {
2525
const response = await aiService.chat.completions.create(params, { signal });
2626
const result = response.choices[0].message?.content;
2727

28-
return result;
28+
return result ?? '';
2929
}
3030

31-
async function getAIResponseRecursive(messages: AIMessage[], signal: AbortSignal): Promise<string | null | undefined> {
31+
async function getAIResponseRecursive(messages: AIMessage[], signal: AbortSignal): Promise<string> {
3232
return getAIResponse(messages, signal)
3333
.catch(async (error) => {
3434
if (!error.message.includes('Connection error')) {
@@ -62,8 +62,8 @@ export const aiIntegration = new AIIntegration({
6262
const signal = controller.signal;
6363

6464
const aiPrompt: AIMessage[] = [
65-
{ role: 'system', content: prompt.system },
66-
{ role: 'user', content: prompt.user },
65+
{ role: 'system', content: prompt.system ?? '' },
66+
{ role: 'user', content: prompt.user ?? '' },
6767
];
6868

6969
const promise = getAIResponseRecursive(aiPrompt, signal);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
22

33
export default function Category(props) {
4-
return <div className="category__wrapper">{props.data.CategoryName}</div>;
4+
return <div className="category__wrapper">{props.data?.CategoryName}</div>;
55
}

apps/demos/Demos/DataGrid/AIColumns/ReactJs/service.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function getAIResponse(messages, signal) {
1919
};
2020
const response = await aiService.chat.completions.create(params, { signal });
2121
const result = response.choices[0].message?.content;
22-
return result;
22+
return result ?? '';
2323
}
2424
async function getAIResponseRecursive(messages, signal) {
2525
return getAIResponse(messages, signal).catch(async (error) => {
@@ -48,8 +48,8 @@ export const aiIntegration = new AIIntegration({
4848
const controller = new AbortController();
4949
const signal = controller.signal;
5050
const aiPrompt = [
51-
{ role: 'system', content: prompt.system },
52-
{ role: 'user', content: prompt.user },
51+
{ role: 'system', content: prompt.system ?? '' },
52+
{ role: 'user', content: prompt.user ?? '' },
5353
];
5454
const promise = getAIResponseRecursive(aiPrompt, signal);
5555
const result = {

apps/demos/Demos/DataGrid/AdvancedMasterDetailView/React/OrderHistory.tsx

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

3+
import type { CustomStore } from 'devextreme-react/common/data';
34
import {
45
Column, DataGrid, Paging, Summary, TotalItem, ValueFormat,
56
} from 'devextreme-react/data-grid';
@@ -12,7 +13,7 @@ interface OrderHistoryProps {
1213
}
1314

1415
const OrderHistory = ({ productId }: OrderHistoryProps) => {
15-
const [orderHistoryStore, setOrderHistoryStore] = useState(null);
16+
const [orderHistoryStore, setOrderHistoryStore] = useState<CustomStore | null>(null);
1617

1718
useEffect(() => {
1819
if (productId) {

apps/demos/Demos/DataGrid/AdvancedMasterDetailView/React/ProductSelectBox.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React, { useCallback, useEffect, useState } from 'react';
2-
import { SelectBox, type SelectBoxTypes } from 'devextreme-react/select-box';
2+
3+
import type { CustomStore } from 'devextreme-react/common/data';
4+
import { SelectBox } from 'devextreme-react/select-box';
5+
import type { SelectBoxTypes } from 'devextreme-react/select-box';
36
import { createStore } from 'devextreme-aspnet-data-nojquery';
47

58
const url = 'https://js.devexpress.com/Demos/NetCore/api/DataGridAdvancedMasterDetailView';
@@ -12,7 +15,7 @@ interface ProductSelectBoxProps {
1215
}
1316

1417
const ProductSelectBox = (props: ProductSelectBoxProps) => {
15-
const [productsData, setProductsData] = useState(null);
18+
const [productsData, setProductsData] = useState<CustomStore | null>(null);
1619

1720
const valueChanged = useCallback((e: SelectBoxTypes.ValueChangedEvent) => {
1821
props.onProductChanged(e.value);

0 commit comments

Comments
 (0)