-
Notifications
You must be signed in to change notification settings - Fork 674
GridCore data: Type DataSourceAdapter public methods and props
#35013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bit-byte0
wants to merge
4
commits into
DevExpress:main
Choose a base branch
from
bit-byte0:refactor/gridcore-datasource-adapter-type-public-surface-26_2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
54b043e
refactor(dataSourceAdapter): type public methods and props
bit-byte0 b2509f9
refactor(treeList): narrow focus _dataSource to drop adapter casts
bit-byte0 58ccbd4
refactor(dataSourceAdapter): type remaining public methods and DataCo…
bit-byte0 ac7e265
fix(treeList): keep incoming parentKey when parent-id getter is absent
bit-byte0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -187,7 +187,7 @@ export class DataController extends modules.Controller { | |||
| */ | ||||
| protected _getPagingOptionValue(optionName: PagingOptionName): number { | ||||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||||
| return this._dataSource![optionName]() as number; | ||||
| return this._dataSource![optionName](); | ||||
| } | ||||
|
|
||||
| protected callbackNames(): string[] { | ||||
|
|
@@ -1179,7 +1179,8 @@ export class DataController extends modules.Controller { | |||
| // change.items at this stage is defined only if virtualScrolling | ||||
| // + legacyScrollingMode enabled | ||||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||||
| const dataItems = this._beforeProcessItems(change.items ?? this._dataSource!.items()); | ||||
| const items = (change.items ?? this._dataSource!.items()) as RawItemData[]; | ||||
| const dataItems = this._beforeProcessItems(items); | ||||
| const processedItems = this._processItems(dataItems, change); | ||||
|
|
||||
| this._cachedProcessedItems = processedItems; | ||||
|
|
@@ -1240,7 +1241,7 @@ export class DataController extends modules.Controller { | |||
| return; | ||||
| } | ||||
|
|
||||
| const operationTypes: OperationTypes | undefined = this.dataSource().operationTypes(); | ||||
| const operationTypes = this.dataSource()?.operationTypes() ?? undefined; | ||||
|
|
||||
| change.isDataChanged = true; | ||||
| change.repaintChangesOnly = resolveRepaintChangesOnly( | ||||
|
|
@@ -1471,13 +1472,12 @@ export class DataController extends modules.Controller { | |||
| return this._dataSource ? this._dataSource.pageCount() : 1; | ||||
| } | ||||
|
|
||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||
| public dataSource(): any { | ||||
| return this._dataSource; | ||||
| public dataSource(): DataSourceAdapter | undefined { | ||||
| return this._dataSource ?? undefined; | ||||
| } | ||||
|
|
||||
| public store(): Store | undefined { | ||||
| return this._dataSource?.store() as Store | undefined; | ||||
| return this._dataSource?.store(); | ||||
| } | ||||
|
|
||||
| public loadAll(data?: RawItemData[], skipFilter = false): DeferredObj<ProcessedItem[]> { | ||||
|
|
@@ -1586,7 +1586,7 @@ export class DataController extends modules.Controller { | |||
| } | ||||
|
|
||||
| if (value === undefined) { | ||||
| return dataSource[optionName]() as number; | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add return type to DevExtreme/packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts Line 1477 in a502ec9
|
||||
| return dataSource[optionName](); | ||||
| } | ||||
|
|
||||
| const oldValue = this._getPagingOptionValue(optionName); | ||||
|
|
@@ -1606,8 +1606,7 @@ export class DataController extends modules.Controller { | |||
| this._skipProcessingPagingChange = false; | ||||
| } | ||||
|
|
||||
| // @ts-expect-error badly typed DataSourceAdapter | ||||
| const pageIndex: number = dataSource.pageIndex(); | ||||
| const pageIndex = dataSource.pageIndex(); | ||||
| this._isPaging = optionName === 'pageIndex'; | ||||
|
|
||||
| const loadResult: DeferredObj<unknown> = dataSource[optionName === 'pageIndex' ? 'load' : 'reload'](); | ||||
|
|
@@ -1733,7 +1732,7 @@ export class DataController extends modules.Controller { | |||
| } | ||||
|
|
||||
| public getCachedStoreData(): RawItemData[] | undefined { | ||||
| return this._dataSource?.getCachedStoreData() as RawItemData[] | undefined; | ||||
| return this._dataSource?.getCachedStoreData(); | ||||
| } | ||||
|
|
||||
| /** | ||||
|
|
@@ -1757,9 +1756,8 @@ export class DataController extends modules.Controller { | |||
| return this._dataSource?.reload(reload, changesOnly) as DeferredObj<unknown>; | ||||
| } | ||||
|
|
||||
| public push(...args: unknown[]): unknown { | ||||
| // @ts-expect-error badly typed DataSourceAdapter | ||||
| return this._dataSource?.push(...args); | ||||
| public push(changes: StoreChange[], fromStore = false): void { | ||||
| this._dataSource?.push(changes, fromStore); | ||||
| } | ||||
|
|
||||
| private itemsCount(): number { | ||||
|
|
@@ -1778,7 +1776,7 @@ export class DataController extends modules.Controller { | |||
| * @extended: state_storing | ||||
| */ | ||||
| public isLoaded(): boolean { | ||||
| return (this._dataSource ? this._dataSource.isLoaded() : true) as boolean; | ||||
| return (this._dataSource ? this._dataSource.isLoaded() : true); | ||||
| } | ||||
|
|
||||
| public totalCount(): number { | ||||
|
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was adding
normalizeSortingInfointentional? Why is it needed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - with the
@ts-expect-errorgone,group()is typedGroupDescriptor | GroupDescriptor[] | undefined, which has no.length.normalizeSortingInfo(group)gives an array to count from, same as in m_grouping.ts