diff --git a/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts b/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts index 6c88b339936..6eb3b73c32a 100644 --- a/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts +++ b/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts @@ -20,10 +20,12 @@ import { AuthProvider } from '../types'; * * const authProvider = addRefreshAuthToAuthProvider(authProvider, refreshAuth); */ -export const addRefreshAuthToAuthProvider = ( - provider: AuthProvider, +export const addRefreshAuthToAuthProvider = < + AuthProviderType extends AuthProvider = AuthProvider +>( + provider: AuthProviderType, refreshAuth: () => Promise -): AuthProvider => { +): AuthProviderType => { const proxy = new Proxy(provider, { get(_, name) { const shouldIntercept = diff --git a/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts b/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts index 100f9d7e723..722bfb463ee 100644 --- a/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts +++ b/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts @@ -19,10 +19,12 @@ import { DataProvider } from '../types'; * * const dataProvider = addRefreshAuthToDataProvider(jsonServerProvider('http://localhost:3000'), refreshAuth); */ -export const addRefreshAuthToDataProvider = ( - provider: DataProvider, +export const addRefreshAuthToDataProvider = < + DataProviderType extends DataProvider = DataProvider +>( + provider: DataProviderType, refreshAuth: () => Promise -): DataProvider => { +): DataProviderType => { const proxy = new Proxy(provider, { get(_, name) { return async (...args: any[]) => {