From 14dfb2d85f6f8d5763fddd45013a230477521270 Mon Sep 17 00:00:00 2001 From: "ilya.kharchenko" <14272298+IlyaKhD@users.noreply.github.com> Date: Fri, 14 Jan 2022 15:12:31 +0300 Subject: [PATCH] Fix DataSource's store prop typings (#20713) --- js/data/data_source.d.ts | 29 +++++++------------ js/data/index.d.ts | 25 ++++++++++++++++ js/ui/pivot_grid/data_source.d.ts | 9 +++--- ts/dx.all.d.ts | 48 +++++++++++++------------------ 4 files changed, 61 insertions(+), 50 deletions(-) diff --git a/js/data/data_source.d.ts b/js/data/data_source.d.ts index 6192cdad6605..097bc585ea09 100644 --- a/js/data/data_source.d.ts +++ b/js/data/data_source.d.ts @@ -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< @@ -147,12 +150,7 @@ export interface DataSourceOptions< * @public * @type Store|StoreOptions|Array */ - store?: Array | - Store | - ArrayStoreOptions & { type: 'array' } | - LocalStoreOptions & { type: 'local' } | - ODataStoreOptions & { type: 'odata' } | - CustomStoreOptions; + store?: Array | Store | StoreOptions; } /** * @docid @@ -436,7 +434,7 @@ export type DataSourceLike = DataSourceOptionsStub | DataSource; - interface DataSourceOptionsStub< +interface DataSourceOptionsStub< TStoreItem = any, TMappedItem = TStoreItem, TItem = TMappedItem, @@ -460,12 +458,7 @@ export type DataSourceLike = searchValue?: any; select?: SelectDescriptor; sort?: SortDescriptor | Array>; - store?: Array | - Store | - ArrayStoreOptions & { type: 'array' } | - LocalStoreOptions & { type: 'local' } | - ODataStoreOptions & { type: 'odata' } | - CustomStoreOptions; + store?: Array | Store | StoreOptions; } type EventName = 'changed' | 'loadError' | 'loadingChanged'; diff --git a/js/data/index.d.ts b/js/data/index.d.ts index 1c6b24a1e33b..cc88c1d746d7 100644 --- a/js/data/index.d.ts +++ b/js/data/index.d.ts @@ -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 @@ -147,3 +152,23 @@ export type SummaryDescriptor = KeySelector | BaseGroupDescriptor & { */ userData?: any; } + +/** + * @public + * @namespace DevExpress.data.utils + */ +export type Store = + CustomStore | + ArrayStore | + LocalStore | + ODataStore; + +/** + * @public + * @namespace DevExpress.data.utils + */ +export type StoreOptions = + CustomStoreOptions | + ArrayStoreOptions & { type: 'array' } | + LocalStoreOptions & { type: 'local' } | + ODataStoreOptions & { type: 'odata' }; diff --git a/js/ui/pivot_grid/data_source.d.ts b/js/ui/pivot_grid/data_source.d.ts index a91aadda1c2b..a91ddab98b30 100644 --- a/js/ui/pivot_grid/data_source.d.ts +++ b/js/ui/pivot_grid/data_source.d.ts @@ -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'; @@ -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 diff --git a/ts/dx.all.d.ts b/ts/dx.all.d.ts index d02ad34ea0e6..cf57d007d9f5 100644 --- a/ts/dx.all.d.ts +++ b/ts/dx.all.d.ts @@ -1709,7 +1709,7 @@ declare module DevExpress.data { | DevExpress.data.CustomStore.Options | DevExpress.data.DataSource.Options ); - constructor(store: Store); + constructor(store: DevExpress.data.utils.Store); constructor(url: string); /** * [descr:DataSource.cancel(operationId)] @@ -1868,7 +1868,7 @@ declare module DevExpress.data { /** * [descr:DataSource.store()] */ - store(): Store; + store(): DevExpress.data.utils.Store; /** * [descr:DataSource.totalCount()] */ @@ -1882,7 +1882,7 @@ declare module DevExpress.data { export type DataSourceLike = | string | Array - | Store + | DevExpress.data.utils.Store | DataSourceOptionsStub | DataSource; /** @@ -1914,17 +1914,8 @@ declare module DevExpress.data { sort?: SortDescriptor | Array>; store?: | Array - | Store - | (DevExpress.data.ArrayStore.Options & { - type: 'array'; - }) - | (DevExpress.data.LocalStore.Options & { - type: 'local'; - }) - | (DevExpress.data.ODataStore.Options & { - type: 'odata'; - }) - | DevExpress.data.CustomStore.Options; + | DevExpress.data.utils.Store + | DevExpress.data.utils.StoreOptions; } /** * @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}. @@ -2028,17 +2019,8 @@ declare module DevExpress.data { */ store?: | Array - | Store - | (DevExpress.data.ArrayStore.Options & { - type: 'array'; - }) - | (DevExpress.data.LocalStore.Options & { - type: 'local'; - }) - | (DevExpress.data.ODataStore.Options & { - type: 'odata'; - }) - | DevExpress.data.CustomStore.Options; + | DevExpress.data.utils.Store + | DevExpress.data.utils.StoreOptions; } /** * [descr:EdmLiteral] @@ -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] @@ -3154,6 +3136,16 @@ declare module DevExpress.data.utils { * [descr:Utils.compileSetter(expr)] */ export function compileSetter(expr: string | Array): Function; + export type Store = + | CustomStore + | ArrayStore + | LocalStore + | ODataStore; + export type StoreOptions = + | DevExpress.data.CustomStore.Options + | (DevExpress.data.ArrayStore.Options & { type: 'array' }) + | (DevExpress.data.LocalStore.Options & { type: 'local' }) + | (DevExpress.data.ODataStore.Options & { type: 'odata' }); } declare module DevExpress.data.utils.odata { /**