diff --git a/packages/ra-core/src/dataProvider/useGetManyReference.spec.tsx b/packages/ra-core/src/dataProvider/useGetManyReference.spec.tsx index af9eb7cd0a5..c282200e37d 100644 --- a/packages/ra-core/src/dataProvider/useGetManyReference.spec.tsx +++ b/packages/ra-core/src/dataProvider/useGetManyReference.spec.tsx @@ -418,4 +418,31 @@ describe('useGetManyReference', () => { expect(abort).toHaveBeenCalled(); }); }); + + it('should discriminate result type', () => { + // this is a TypeScript verification. It should compile. + const _ComponentToTest = () => { + const { data, error, isPending } = useGetManyReference<{ + id: number; + title: string; + }>('posts', { + target: 'comments', + id: 1, + }); + if (isPending) { + return <>Loading>; + } + if (error) { + return <>Error>; + } + return ( +