d.ts - Replace [Smth]Options members of 'Function' type (smthExpr) to more specific to keep exact signature in generated wrappers#33285
Conversation
d876066 to
e8042a5
Compare
128a088 to
2c61fc3
Compare
There was a problem hiding this comment.
Pull request overview
This PR tightens TypeScript declaration types for various *Expr options across DevExtreme core .d.ts files and the generated Angular/React/Vue wrappers, replacing broad Function types with explicit callable signatures to preserve more exact typings in wrapper generation.
Changes:
- Replaced
Function-typed*Exprmembers with explicit function signatures in core.d.tsfiles (anddx.all.d.ts). - Updated generated Angular/React/Vue wrapper prop/input typings to reflect the new callable signatures.
- Adjusted related option typings for TreeView/TreeList/Gantt/FileManagement and Collection/Hierarchical widgets.
Reviewed changes
Copilot reviewed 43 out of 53 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/ts/dx.all.d.ts | Aggregated declarations updated to use explicit callback signatures instead of Function. |
| packages/devextreme/js/ui/tree_view.d.ts | TreeView option *Expr callback typings updated. |
| packages/devextreme/js/ui/tree_list.d.ts | TreeList option *Expr callback typings updated. |
| packages/devextreme/js/ui/tab_panel.d.ts | TabPanel keyExpr typing updated. |
| packages/devextreme/js/ui/hierarchical_collection/ui.hierarchical_collection_widget.d.ts | Hierarchical widget *Expr callback typings updated. |
| packages/devextreme/js/ui/gantt.d.ts | Gantt nested *Expr callback typings updated. |
| packages/devextreme/js/ui/collection/ui.collection_widget.base.d.ts | Collection widget keyExpr typing updated. |
| packages/devextreme/js/ui/button_group.d.ts | ButtonGroup keyExpr typing updated (and imports adjusted). |
| packages/devextreme/js/file_management/provider_base.d.ts | File management provider base *Expr callback typings updated. |
| packages/devextreme/js/file_management/object_provider.d.ts | Object provider contentExpr/itemsExpr callback typings updated. |
| packages/devextreme-vue/src/tree-view.ts | Vue TreeView prop typings updated for *Expr options. |
| packages/devextreme-vue/src/tree-list.ts | Vue TreeList/TabPanel options prop typings updated for *Expr options. |
| packages/devextreme-vue/src/tabs.ts | Vue Tabs prop typing updated for keyExpr. |
| packages/devextreme-vue/src/tab-panel.ts | Vue TabPanel prop typing updated for keyExpr. |
| packages/devextreme-vue/src/scheduler.ts | Vue Scheduler nested option prop typings updated for keyExpr. |
| packages/devextreme-vue/src/menu.ts | Vue Menu prop typings updated for disabledExpr/itemsExpr/selectedExpr. |
| packages/devextreme-vue/src/list.ts | Vue List prop typing updated for keyExpr. |
| packages/devextreme-vue/src/gantt.ts | Vue Gantt nested option prop typings updated for multiple *Expr options. |
| packages/devextreme-vue/src/form.ts | Vue Form nested TabPanel options prop typing updated for keyExpr. |
| packages/devextreme-vue/src/data-grid.ts | Vue DataGrid nested TabPanel options prop typing updated for keyExpr. |
| packages/devextreme-vue/src/context-menu.ts | Vue ContextMenu prop typings updated for disabledExpr/itemsExpr/selectedExpr. |
| packages/devextreme-vue/src/chat.ts | Vue Chat nested suggestions prop typing updated for keyExpr. |
| packages/devextreme-vue/src/card-view.ts | Vue CardView nested TabPanel options prop typing updated for keyExpr. |
| packages/devextreme-vue/src/button-group.ts | Vue ButtonGroup prop typing updated for keyExpr. |
| packages/devextreme-vue/src/accordion.ts | Vue Accordion prop typing updated for keyExpr. |
| packages/devextreme-react/src/tree-list.ts | React TreeList nested TabPanel options prop typing updated for keyExpr. |
| packages/devextreme-react/src/scheduler.ts | React Scheduler option typings updated for keyExpr (incl. nested TabPanel options). |
| packages/devextreme-react/src/gantt.ts | React Gantt nested option prop typings updated for multiple *Expr options. |
| packages/devextreme-react/src/form.ts | React Form nested TabPanel options prop typing updated for keyExpr. |
| packages/devextreme-react/src/data-grid.ts | React DataGrid nested TabPanel options prop typing updated for keyExpr. |
| packages/devextreme-react/src/chat.ts | React Chat nested suggestions prop typing updated for keyExpr. |
| packages/devextreme-react/src/card-view.ts | React CardView nested TabPanel options prop typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/tree-view/index.ts | Angular TreeView inputs/outputs updated for *Expr callback typings. |
| packages/devextreme-angular/src/ui/tree-list/nested/tab-panel-options.ts | Angular TreeList nested TabPanel options input typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/tree-list/index.ts | Angular TreeList inputs/outputs updated for *Expr callback typings. |
| packages/devextreme-angular/src/ui/tabs/index.ts | Angular Tabs input/output typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/tab-panel/index.ts | Angular TabPanel input/output typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/scheduler/nested/tab-panel-options.ts | Angular Scheduler nested TabPanel options input typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/scheduler/nested/options.ts | Angular Scheduler nested options input typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/menu/index.ts | Angular Menu inputs/outputs updated for disabledExpr/itemsExpr/selectedExpr typings. |
| packages/devextreme-angular/src/ui/list/index.ts | Angular List input/output typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/gantt/nested/tasks.ts | Angular Gantt Tasks nested option inputs updated for *Expr typings. |
| packages/devextreme-angular/src/ui/gantt/nested/resources.ts | Angular Gantt Resources nested option inputs updated for *Expr typings. |
| packages/devextreme-angular/src/ui/gantt/nested/resource-assignments.ts | Angular Gantt ResourceAssignments nested option inputs updated for *Expr typings. |
| packages/devextreme-angular/src/ui/gantt/nested/dependencies.ts | Angular Gantt Dependencies nested option inputs updated for *Expr typings. |
| packages/devextreme-angular/src/ui/gantt/index.ts | Angular Gantt inputs/outputs updated for nested *Expr option object typings. |
| packages/devextreme-angular/src/ui/form/nested/tab-panel-options.ts | Angular Form nested TabPanel options input typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/data-grid/nested/tab-panel-options.ts | Angular DataGrid nested TabPanel options input typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/context-menu/index.ts | Angular ContextMenu inputs/outputs updated for disabledExpr/itemsExpr/selectedExpr typings. |
| packages/devextreme-angular/src/ui/chat/nested/suggestions.ts | Angular Chat Suggestions nested option input typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/card-view/nested/tab-panel-options.ts | Angular CardView nested TabPanel options input typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/button-group/index.ts | Angular ButtonGroup input/output typing updated for keyExpr. |
| packages/devextreme-angular/src/ui/accordion/index.ts | Angular Accordion input/output typing updated for keyExpr. |
| } from '../events'; | ||
|
|
||
| import { | ||
| CollectionWidgetOptions, |
smthExpr) to more specific to keep exact signature in generated wrappers
| * @public | ||
| */ | ||
| itemsExpr?: string | Function; | ||
| itemsExpr?: string | ((item: TRowData, value?: any) => TKey); |
There was a problem hiding this comment.
If itemsExpr is a function, then it accepts only one parameter, according to this code (there are no other usages of itemsGetter).
Moreover, it should return an array of items, not the key.
So the type should be:
itemsExpr?: string | ((item: TRowData) => TRowData[]);| * @public | ||
| */ | ||
| parentIdExpr?: string | Function; | ||
| parentIdExpr?: string | ((item: TRowData, value?: any) => TKey); |
There was a problem hiding this comment.
if parentIdExpr is function, then it accepts only one parameter (check usages of _parentIdGetter in this file).
So its type should be this:
parentIdExpr?: string | ((item: TRowData) => TKey);There was a problem hiding this comment.
Here _parentIdSetter called with two arguments (item, value).
In createParentIdSetter, when parentIdExpr is a function, it is returned as-is, so the same user callback is used as a setter too.
Therefore, I think parentIdExpr is effectively a dual-mode getter/setter callback in this adapter, and the two-argument signature is expected.
| * @public | ||
| */ | ||
| hasItemsExpr?: string | Function; | ||
| hasItemsExpr?: string | ((item: TRowData) => TKey); |
There was a problem hiding this comment.
I am not sure if it should return TKey. TKey is a type of key, hasItemsExpr doesn't return a key, so its return type should be different.
Judging by the usage, the type should be this:
hasItemsExpr?: string | ((item: TRowData) => boolean);There was a problem hiding this comment.
Please take a look at all other widget's d.ts files. I think they might have similar mistakes, e.g. here: https://github.com/DevExpress/DevExtreme/pull/33285/changes#diff-6698d8890476361148d70e40dd836b58e198b3e1f2932aaea589bb91d264102dR22
There was a problem hiding this comment.
Agree on the return type: hasItemsExpr should be boolean-like rather than TKey.
Also, I noticed this callback is used not only as a getter but also as a setter in the adapter here and here, so I added the second argument to the function signature as well.
hasItemsExpr?: string | ((item: TRowData, value?: boolean) => boolean | undefined);There was a problem hiding this comment.
and about disabledExpr, agree, fixed returned type
| * @public | ||
| */ | ||
| hasItemsExpr?: string | Function; | ||
| hasItemsExpr?: string | ((item: TItem) => TKey); |
There was a problem hiding this comment.
I am not sure about treeView impl, but I suspect it should be similar to treeLists hasItemsExpr:
https://github.com/DevExpress/DevExtreme/pull/33285/changes#r3111399000
Please take a look
| * @public | ||
| */ | ||
| expandedExpr?: string | Function; | ||
| expandedExpr?: string | ((item: TItem) => TKey); |
There was a problem hiding this comment.
I suspect it should return boolean:
expandedExpr?: string | ((item: TItem) => boolean);Can you check plz?
| * @public | ||
| */ | ||
| parentIdExpr?: string | Function; | ||
| parentIdExpr?: string | ((item: TItem, value?: any) => TKey); |
There was a problem hiding this comment.
Are you sure it accepts two parameters?
There was a problem hiding this comment.
Checked it again and removed additional argument
391e610
No description provided.