Skip to content

[TypeScript] Fix withLifecycleCallback return type for augmented data providers#11170

Merged
slax57 merged 2 commits intomasterfrom
Fix-withLifecycleCallback-return-type
Feb 24, 2026
Merged

[TypeScript] Fix withLifecycleCallback return type for augmented data providers#11170
slax57 merged 2 commits intomasterfrom
Fix-withLifecycleCallback-return-type

Conversation

@fzaninotto
Copy link
Member

Problem

withLifecycleCallbacks always returns an object of type DataProvider.

This can be an issue when developers add custom methods to the data provider and use a custom type. In that case, the original type is lost.

Solution

Infer the return type from the data generator param type.

How To Test

New unit test added.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • [ ] The PR includes one or several stories (if not possible, describe why)
  • [ ] The documentation is up to date

dataProvider.getMany('posts', { ids: [1, 2] });
expect(resourceCallback.beforeGetMany).toHaveBeenCalled();
});
it('should return the right type for augmented Data Providers', async () => {
Copy link
Collaborator

@WiXSL WiXSL Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test still passes with the old dataProvider return signature

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but the test itself doesn't pass TS compilation unless e do the change.

@slax57 slax57 added this to the 5.14.3 milestone Feb 24, 2026
@slax57 slax57 merged commit a6e5977 into master Feb 24, 2026
15 checks passed
@slax57 slax57 deleted the Fix-withLifecycleCallback-return-type branch February 24, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants