Skip to content

Commit

Permalink
TypeScript - CustomStore onLoaded result own param type (T1197789) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mpreyskurantov authored Dec 22, 2023
1 parent c5a5558 commit 35147f4
Show file tree
Hide file tree
Showing 17 changed files with 375 additions and 334 deletions.
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/data-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { ContentReadyEvent as FormContentReadyEvent, DisposingEvent as Form
import type { AnimationConfig, AnimationState } from "devextreme/animation/fx";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";
import type { PositionConfig } from "devextreme/animation/position";
import type { dxPopupOptions, dxPopupToolbarItem } from "devextreme/ui/popup";
import type { event, EventInfo } from "devextreme/events/index";
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ContentReadyEvent, CustomCommandEvent, DisposingEvent, Initialized
import type { dxSVGElement } from "devextreme/core/element";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";

import type DataSource from "devextreme/data/data_source";

Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/filter-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NestedOption from "./core/nested-option";
import type { ContentReadyEvent, DisposingEvent, EditorPreparedEvent, EditorPreparingEvent, InitializedEvent, ValueChangedEvent, dxFilterBuilderField } from "devextreme/ui/filter_builder";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";

import type * as LocalizationTypes from "devextreme/localization";

Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { ContentReadyEvent as TabPanelContentReadyEvent, DisposingEvent as
import type { template } from "devextreme/core/templates/template";
import type { CollectionWidgetItem } from "devextreme/ui/collection/ui.collection_widget.base";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";

import type DataSource from "devextreme/data/data_source";

Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/gantt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ContentReadyEvent, ContextMenuPreparingEvent, CustomCommandEvent,
import type { dxTreeListColumn, dxTreeListRowObject } from "devextreme/ui/tree_list";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";
import type { ColumnHeaderFilterSearchConfig, HeaderFilterSearchConfig } from "devextreme/common/grids";
import type { dxContextMenuItem } from "devextreme/ui/context_menu";
import type { CollectionWidgetItem } from "devextreme/ui/collection/ui.collection_widget.base";
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/html-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ContentReadyEvent as FileUploaderContentReadyEvent, DisposingEvent
import type { CollectionWidgetItem } from "devextreme/ui/collection/ui.collection_widget.base";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";

import type UploadInfo from "devextreme/file_management/upload_info";
import type DataSource from "devextreme/data/data_source";
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NestedOption from "./core/nested-option";
import type { AppointmentAddedEvent, AppointmentAddingEvent, AppointmentClickEvent, AppointmentContextMenuEvent, AppointmentDblClickEvent, AppointmentDeletedEvent, AppointmentDeletingEvent, AppointmentFormOpeningEvent, AppointmentRenderedEvent, AppointmentTooltipShowingEvent, AppointmentUpdatedEvent, AppointmentUpdatingEvent, CellClickEvent, CellContextMenuEvent, ContentReadyEvent, DisposingEvent, InitializedEvent, AppointmentTemplateData, AppointmentTooltipTemplateData, dxSchedulerScrolling } from "devextreme/ui/scheduler";
import type { event } from "devextreme/events/index";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";
import type { template } from "devextreme/core/templates/template";

import type dxSortable from "devextreme/ui/sortable";
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/tree-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { AnimationConfig, AnimationState } from "devextreme/animation/fx";
import type { event, EventInfo } from "devextreme/events/index";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";
import type { PositionConfig } from "devextreme/animation/position";
import type { dxPopupOptions, dxPopupToolbarItem } from "devextreme/ui/popup";
import type { Component } from "devextreme/core/component";
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme-react/src/vector-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ClickEvent, DisposingEvent, DrawnEvent, ExportedEvent, ExportingEv
import type { Font as ChartsFont } from "devextreme/common/charts";
import type { template } from "devextreme/core/templates/template";
import type { DataSourceOptions } from "devextreme/data/data_source";
import type { Store } from "devextreme/data/abstract_store";
import type { Store } from "devextreme/data/store";

import type DataSource from "devextreme/data/data_source";

Expand Down
271 changes: 48 additions & 223 deletions packages/devextreme/js/data/abstract_store.d.ts
Original file line number Diff line number Diff line change
@@ -1,243 +1,68 @@
// eslint-disable-next-line max-classes-per-file
import {
DxPromise,
DxExtendedPromise,
} from '../core/utils/deferred';
import { DeepPartial } from '../core/index';
import {
FilterDescriptor,
GroupDescriptor,
Store as BaseStore,
Options as BaseStoreOptions,
} from './store';
import {
LoadOptions,
} from './index';

export type Options<
TItem = any,
TKey = any,
> = StoreOptions<TItem, TKey>;
TItem = any,
TKey = any,
> = AbstractStoreOptions<TItem, TKey>;

/**
* @namespace DevExpress.data
* @deprecated Use Options instead
* @docid
* @hidden
*/
export interface StoreOptions<
TItem = any,
TKey = any,
> {
/**
* @docid
* @public
*/
errorHandler?: Function;
/**
* @docid
* @public
*/
key?: string | Array<string>;
/**
* @docid
* @type_function_param1 values:object
* @type_function_param2 key:object|string|number
* @action
* @public
*/
onInserted?: ((values: TItem, key: TKey) => void);
/**
* @docid
* @type_function_param1 values:object
* @action
* @public
*/
onInserting?: ((values: TItem) => void);
/**
* @docid
* @type_function_param2 loadOptions:LoadOptions
* @action
* @public
*/
onLoaded?: ((result: Array<TItem>, loadOptions: LoadOptions<TItem>) => void);
/**
* @docid
* @type_function_param1 loadOptions:LoadOptions
* @action
* @public
*/
onLoading?: ((loadOptions: LoadOptions<TItem>) => void);
/**
* @docid
* @action
* @public
*/
onModified?: Function;
/**
* @docid
* @action
* @public
*/
onModifying?: Function;
/**
* @docid
* @action
* @public
*/
onPush?: ((changes: Array<TItem>) => void);
/**
* @docid
* @type_function_param1 key:object|string|number
* @action
* @public
*/
onRemoved?: ((key: TKey) => void);
/**
* @docid
* @type_function_param1 key:object|string|number
* @action
* @public
*/
onRemoving?: ((key: TKey) => void);
/**
* @docid
* @type_function_param1 key:object|string|number
* @type_function_param2 values:object
* @action
* @public
*/
onUpdated?: ((key: TKey, values: TItem) => void);
/**
* @docid
* @type_function_param1 key:object|string|number
* @type_function_param2 values:object
* @action
* @public
*/
onUpdating?: ((key: TKey, values: TItem) => void);
interface AbstractStoreOptions<
TItem = any,
TKey = any,
> extends BaseStoreOptions<TItem, TKey> {
/**
* @docid StoreOptions.onLoaded
* @type_function_param2 loadOptions:LoadOptions
* @action
* @public
*/
onLoaded?: ((result: Array<TItem>, loadOptions: LoadOptions<TItem>) => void);
}

type EventName = 'loaded' | 'loading' | 'inserted' | 'inserting' | 'updated' | 'updating' | 'push' | 'removed' | 'removing' | 'modified' | 'modifying';

/**
* @docid Store
* @hidden
* @namespace DevExpress.data
* @options StoreOptions
*/
export class Store<
TItem = any,
TKey = any,
> {
constructor(options?: Options<TItem, TKey>);
/**
* @docid
* @publicName insert(values)
* @param1 values:object
* @return Promise<any>
* @public
*/
insert(values: TItem): DxExtendedPromise<TItem>;
/**
* @docid
* @publicName key()
* @public
*/
key(): string | Array<string>;
/**
* @docid
* @publicName keyOf(obj)
* @param1 obj:object
* @return any|string|number
* @public
*/
keyOf(obj: TItem): TKey;
/**
* @docid
* @publicName off(eventName)
* @param1 eventName:string
* @return this
* @public
*/
off(eventName: EventName): this;
/**
* @docid
* @publicName off(eventName, eventHandler)
* @param1 eventName:string
* @return this
* @public
*/
off(eventName: EventName, eventHandler: Function): this;
/**
* @docid
* @publicName on(eventName, eventHandler)
* @param1 eventName:string
* @return this
* @public
*/
on(eventName: EventName, eventHandler: Function): this;
/**
* @docid
* @publicName on(events)
* @param1 events:object
* @return this
* @public
*/
on(events: { [key in EventName]?: Function }): this;
/**
* @docid
* @publicName push(changes)
* @param1 changes:Array<any>
* @public
*/
push(changes: Array<{ type: 'insert' | 'update' | 'remove'; data?: DeepPartial<TItem>; key?: TKey; index?: number }>): void;
/**
* @docid
* @publicName remove(key)
* @param1 key:object|string|number
* @return Promise<void>
* @public
*/
remove(key: TKey): DxPromise<void>;
/**
* @docid
* @publicName totalCount(options)
* @param1_field filter:object
* @param1_field group:object
* @return Promise<number>
* @public
*/
totalCount(obj: { filter?: FilterDescriptor | Array<FilterDescriptor>; group?: GroupDescriptor<TItem> | Array<GroupDescriptor<TItem>> }): DxPromise<number>;
/**
* @docid
* @publicName update(key, values)
* @param1 key:object|string|number
* @param2 values:object
* @return Promise<any>
* @public
*/
update(key: TKey, values: DeepPartial<TItem>): DxExtendedPromise<TItem>;
}

export default class AbstractStore<
TItem = any,
TKey = any,
> extends BaseStore<TItem, TKey> {
constructor(options?: Options<TItem, TKey>);
/**
* @docid Store.load()
* @publicName load()
* @return Promise<any>
* @public
*/
load(): DxExtendedPromise<Array<TItem>>;
/**
* @namespace DevExpress.data
* @docid Store.load(options)
* @publicName load(options)
* @param1 options:LoadOptions
* @return Promise<any>
* @public
*/
export default class AbstractStore<
TItem = any,
TKey = any,
> extends Store<TItem, TKey> {
constructor(options?: Options<TItem, TKey>);
/**
* @docid Store.load()
* @publicName load()
* @return Promise<any>
* @public
*/
load(): DxExtendedPromise<Array<TItem>>;
load(options: LoadOptions<TItem>): DxExtendedPromise<Array<TItem>>;
}

/**
* @namespace DevExpress.data
* @deprecated Use Options from data/store instead
*/
export type StoreOptions<TItem = any, TKey = any> = BaseStoreOptions<TItem, TKey>;

/**
* @docid Store.load(options)
* @publicName load(options)
* @param1 options:LoadOptions
* @return Promise<any>
* @public
*/
load(options: LoadOptions<TItem>): DxExtendedPromise<Array<TItem>>;
}
/**
* @namespace DevExpress.data
* @deprecated Use Store from data/store instead
*/
export type Store<TItem = any, TKey = any> = BaseStore<TItem, TKey>;
3 changes: 2 additions & 1 deletion packages/devextreme/js/data/array_store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export type Options<
> = ArrayStoreOptions<TItem, TKey>;

/**
* @docid
* @namespace DevExpress.data
* @deprecated Use Options instead
* @docid
*/
export interface ArrayStoreOptions<
TItem = any,
Expand All @@ -25,6 +25,7 @@ export interface ArrayStoreOptions<
*/
data?: Array<TItem>;
}

/**
* @docid
* @inherits Store
Expand Down
Loading

0 comments on commit 35147f4

Please sign in to comment.