Skip to content

Commit

Permalink
Fix DataSource's store prop typings (#20713)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaKhD authored Jan 14, 2022
1 parent dde10ad commit 14dfb2d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 50 deletions.
29 changes: 11 additions & 18 deletions js/data/data_source.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {
FilterDescriptor, GroupDescriptor, SelectDescriptor, SortDescriptor, LoadOptions, SearchOperation,
FilterDescriptor,
GroupDescriptor,
LoadOptions,
SearchOperation,
SelectDescriptor,
SortDescriptor,
Store,
StoreOptions,
} from './index';
import { DxPromise } from '../core/utils/deferred';
import Store from './abstract_store';
import { Options as CustomStoreOptions } from './custom_store';
import { Options as ArrayStoreOptions } from './array_store';
import { Options as LocalStoreOptions } from './local_store';
import { Options as ODataStoreOptions } from './odata/store';

/** @public */
export type Options<
Expand Down Expand Up @@ -147,12 +150,7 @@ export interface DataSourceOptions<
* @public
* @type Store|StoreOptions|Array<any>
*/
store?: Array<TStoreItem> |
Store<TStoreItem, TKey> |
ArrayStoreOptions<TStoreItem, TKey> & { type: 'array' } |
LocalStoreOptions<TStoreItem, TKey> & { type: 'local' } |
ODataStoreOptions<TStoreItem, TKey> & { type: 'odata' } |
CustomStoreOptions<TStoreItem, TKey>;
store?: Array<TStoreItem> | Store<TStoreItem, TKey> | StoreOptions<TStoreItem, TKey>;
}
/**
* @docid
Expand Down Expand Up @@ -436,7 +434,7 @@ export type DataSourceLike<TItem, TKey = any> =
DataSourceOptionsStub<any, any, TItem> |
DataSource<TItem, TKey>;

interface DataSourceOptionsStub<
interface DataSourceOptionsStub<
TStoreItem = any,
TMappedItem = TStoreItem,
TItem = TMappedItem,
Expand All @@ -460,12 +458,7 @@ export type DataSourceLike<TItem, TKey = any> =
searchValue?: any;
select?: SelectDescriptor<TItem>;
sort?: SortDescriptor<TItem> | Array<SortDescriptor<TItem>>;
store?: Array<TStoreItem> |
Store<TStoreItem, any> |
ArrayStoreOptions<TStoreItem, any> & { type: 'array' } |
LocalStoreOptions<TStoreItem, any> & { type: 'local' } |
ODataStoreOptions<TStoreItem, any> & { type: 'odata' } |
CustomStoreOptions<TStoreItem, any>;
store?: Array<TStoreItem> | Store<TStoreItem, any> | StoreOptions<TStoreItem, any>;
}

type EventName = 'changed' | 'loadError' | 'loadingChanged';
25 changes: 25 additions & 0 deletions js/data/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import CustomStore, { Options as CustomStoreOptions } from './custom_store';
import ArrayStore, { Options as ArrayStoreOptions } from './array_store';
import LocalStore, { Options as LocalStoreOptions } from './local_store';
import ODataStore, { Options as ODataStoreOptions } from './odata/store';

/**
* @docid
* @public
Expand Down Expand Up @@ -147,3 +152,23 @@ export type SummaryDescriptor<T> = KeySelector<T> | BaseGroupDescriptor<T> & {
*/
userData?: any;
}

/**
* @public
* @namespace DevExpress.data.utils
*/
export type Store<TItem = any, TKey = any> =
CustomStore<TItem, TKey> |
ArrayStore<TItem, TKey> |
LocalStore<TItem, TKey> |
ODataStore<TItem, TKey>;

/**
* @public
* @namespace DevExpress.data.utils
*/
export type StoreOptions<TItem = any, TKey = any> =
CustomStoreOptions<TItem, TKey> |
ArrayStoreOptions<TItem, TKey> & { type: 'array' } |
LocalStoreOptions<TItem, TKey> & { type: 'local' } |
ODataStoreOptions<TItem, TKey> & { type: 'odata' };
9 changes: 5 additions & 4 deletions js/ui/pivot_grid/data_source.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import {
DxPromise,
} from '../../core/utils/deferred';

import Store, {
Options as StoreOptions,
} from '../../data/abstract_store';
import {
Store,
StoreOptions,
} from '../../data/index';

import DataSource from '../../data/data_source';

Expand Down Expand Up @@ -196,7 +197,7 @@ export interface PivotGridDataSourceOptions {
* @docid
* @public
*/
store?: Store | StoreOptions | XmlaStore | XmlaStoreOptions | Array<{
store?: Store | StoreOptions | XmlaStore | (XmlaStoreOptions & { type: 'xmla' }) | Array<{
/**
* @docid
* @type Enums.PivotGridStoreType
Expand Down
48 changes: 20 additions & 28 deletions ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ declare module DevExpress.data {
| DevExpress.data.CustomStore.Options<TItem, TKey>
| DevExpress.data.DataSource.Options<any, any, TItem, TKey>
);
constructor(store: Store<TItem, TKey>);
constructor(store: DevExpress.data.utils.Store<TItem, TKey>);
constructor(url: string);
/**
* [descr:DataSource.cancel(operationId)]
Expand Down Expand Up @@ -1868,7 +1868,7 @@ declare module DevExpress.data {
/**
* [descr:DataSource.store()]
*/
store(): Store<TItem, TKey>;
store(): DevExpress.data.utils.Store<TItem, TKey>;
/**
* [descr:DataSource.totalCount()]
*/
Expand All @@ -1882,7 +1882,7 @@ declare module DevExpress.data {
export type DataSourceLike<TItem, TKey = any> =
| string
| Array<TItem>
| Store<TItem, TKey>
| DevExpress.data.utils.Store<TItem, TKey>
| DataSourceOptionsStub<any, any, TItem>
| DataSource<TItem, TKey>;
/**
Expand Down Expand Up @@ -1914,17 +1914,8 @@ declare module DevExpress.data {
sort?: SortDescriptor<TItem> | Array<SortDescriptor<TItem>>;
store?:
| Array<TStoreItem>
| Store<TStoreItem, any>
| (DevExpress.data.ArrayStore.Options<TStoreItem, any> & {
type: 'array';
})
| (DevExpress.data.LocalStore.Options<TStoreItem, any> & {
type: 'local';
})
| (DevExpress.data.ODataStore.Options<TStoreItem, any> & {
type: 'odata';
})
| DevExpress.data.CustomStore.Options<TStoreItem, any>;
| DevExpress.data.utils.Store<TStoreItem, any>
| DevExpress.data.utils.StoreOptions<TStoreItem, any>;
}
/**
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please describe your scenario in the following GitHub Issue, and we will suggest a public alternative: {@link https://github.com/DevExpress/DevExtreme/issues/17885|Internal Types}.
Expand Down Expand Up @@ -2028,17 +2019,8 @@ declare module DevExpress.data {
*/
store?:
| Array<TStoreItem>
| Store<TStoreItem, TKey>
| (DevExpress.data.ArrayStore.Options<TStoreItem, TKey> & {
type: 'array';
})
| (DevExpress.data.LocalStore.Options<TStoreItem, TKey> & {
type: 'local';
})
| (DevExpress.data.ODataStore.Options<TStoreItem, TKey> & {
type: 'odata';
})
| DevExpress.data.CustomStore.Options<TStoreItem, TKey>;
| DevExpress.data.utils.Store<TStoreItem, TKey>
| DevExpress.data.utils.StoreOptions<TStoreItem, TKey>;
}
/**
* [descr:EdmLiteral]
Expand Down Expand Up @@ -2781,10 +2763,10 @@ declare module DevExpress.data {
* [descr:PivotGridDataSourceOptions.store]
*/
store?:
| Store
| DevExpress.data.Store.Options
| DevExpress.data.utils.Store
| DevExpress.data.utils.StoreOptions
| XmlaStore
| XmlaStoreOptions
| (XmlaStoreOptions & { type: 'xmla' })
| Array<{
/**
* [descr:PivotGridDataSourceOptions.store.type]
Expand Down Expand Up @@ -3154,6 +3136,16 @@ declare module DevExpress.data.utils {
* [descr:Utils.compileSetter(expr)]
*/
export function compileSetter(expr: string | Array<string>): Function;
export type Store<TItem = any, TKey = any> =
| CustomStore<TItem, TKey>
| ArrayStore<TItem, TKey>
| LocalStore<TItem, TKey>
| ODataStore<TItem, TKey>;
export type StoreOptions<TItem = any, TKey = any> =
| DevExpress.data.CustomStore.Options<TItem, TKey>
| (DevExpress.data.ArrayStore.Options<TItem, TKey> & { type: 'array' })
| (DevExpress.data.LocalStore.Options<TItem, TKey> & { type: 'local' })
| (DevExpress.data.ODataStore.Options<TItem, TKey> & { type: 'odata' });
}
declare module DevExpress.data.utils.odata {
/**
Expand Down

0 comments on commit 14dfb2d

Please sign in to comment.