Skip to content

Commit f276d85

Browse files
DataGrid Custom Data Source Demo - Fix typings (#31906)
1 parent e4e099f commit f276d85

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

apps/demos/Demos/DataGrid/CustomDataSource/Angular/app/app.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
44
import { HttpClient, HttpClientModule, HttpParams } from '@angular/common/http';
55
import { lastValueFrom } from 'rxjs';
66
import { DxDataGridModule } from 'devextreme-angular';
7-
import { CustomStore, LoadOptions } from 'devextreme-angular/common/data';
7+
import { CustomStore, type LoadOptions, type LoadResultObject } from 'devextreme-angular/common/data';
88

99
if (!/localhost/.test(document.location.host)) {
1010
enableProdMode();
@@ -21,9 +21,7 @@ if (window && window.config?.packageConfigPaths) {
2121
templateUrl: `.${modulePrefix}/app.component.html`,
2222
})
2323
export class AppComponent {
24-
url: string;
25-
26-
dataSource = {} as CustomStore;
24+
dataSource: CustomStore;
2725

2826
constructor(httpClient: HttpClient) {
2927
const isNotEmpty = (value: unknown) => (value !== undefined && value !== null && value !== '');
@@ -33,7 +31,7 @@ export class AppComponent {
3331
async load(loadOptions: LoadOptions) {
3432
const url = 'https://js.devexpress.com/Demos/WidgetsGalleryDataService/api/orders';
3533

36-
const paramNames = [
34+
const paramNames: (keyof LoadOptions)[] = [
3735
'skip', 'take', 'requireTotalCount', 'requireGroupCount',
3836
'sort', 'filter', 'totalSummary', 'group', 'groupSummary',
3937
];
@@ -47,7 +45,7 @@ export class AppComponent {
4745
});
4846

4947
try {
50-
const result = await lastValueFrom(httpClient.get(url, { params })) as Record<string, unknown>;
48+
const result = await lastValueFrom(httpClient.get<LoadResultObject>(url, { params }));
5149

5250
return {
5351
data: result.data,

apps/demos/Demos/DataGrid/CustomDataSource/React/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import React from 'react';
22

33
import DataGrid, { Column, Paging, Pager } from 'devextreme-react/data-grid';
4-
import { CustomStore } from 'devextreme-react/common/data';
4+
import { CustomStore, type LoadOptions, type LoadResultObject } from 'devextreme-react/common/data';
55
import 'whatwg-fetch';
66

7-
function isNotEmpty(value: string | undefined | null) {
7+
function isNotEmpty(value: unknown) {
88
return value !== undefined && value !== null && value !== '';
99
}
1010

1111
const store = new CustomStore({
1212
key: 'OrderNumber',
13-
async load(loadOptions) {
14-
const paramNames = [
13+
async load(loadOptions: LoadOptions) {
14+
const paramNames: (keyof LoadOptions)[] = [
1515
'skip', 'take', 'requireTotalCount', 'requireGroupCount',
1616
'sort', 'filter', 'totalSummary', 'group', 'groupSummary',
1717
];
@@ -24,7 +24,7 @@ const store = new CustomStore({
2424
try {
2525
const response = await fetch(`https://js.devexpress.com/Demos/WidgetsGalleryDataService/api/orders?${queryString}`);
2626

27-
const result = await response.json();
27+
const result = await response.json() as LoadResultObject;
2828

2929
return {
3030
data: result.data,

apps/demos/Demos/DataGrid/CustomDataSource/Vue/App.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@
4141
import {
4242
DxDataGrid, DxColumn, DxPaging, DxPager,
4343
} from 'devextreme-vue/data-grid';
44-
import { CustomStore } from 'devextreme-vue/common/data';
44+
import { CustomStore, type LoadOptions, type LoadResultObject } from 'devextreme-vue/common/data';
4545
import 'whatwg-fetch';
4646
47-
const isNotEmpty = (value: any) => value !== undefined && value !== null && value !== '';
47+
const isNotEmpty = (value: unknown) => value !== undefined && value !== null && value !== '';
4848
4949
const store = new CustomStore({
5050
key: 'OrderNumber',
51-
async load(loadOptions) {
52-
const paramNames = [
51+
async load(loadOptions: LoadOptions) {
52+
const paramNames: (keyof LoadOptions)[] = [
5353
'skip', 'take', 'requireTotalCount', 'requireGroupCount',
5454
'sort', 'filter', 'totalSummary', 'group', 'groupSummary',
55-
] as const;
55+
];
5656
5757
const queryString = paramNames
5858
.filter((paramName) => isNotEmpty(loadOptions[paramName]))
@@ -62,7 +62,7 @@ const store = new CustomStore({
6262
try {
6363
const response = await fetch(`https://js.devexpress.com/Demos/WidgetsGalleryDataService/api/orders?${queryString}`);
6464
65-
const result = await response.json();
65+
const result = await response.json() as LoadResultObject;
6666
6767
return {
6868
data: result.data,

0 commit comments

Comments
 (0)