Skip to content
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

[TypeScript] Allow to pass custom provider types to addRefreshAuth functions #9428

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>
): AuthProvider => {
): AuthProviderType => {
const proxy = new Proxy(provider, {
get(_, name) {
const shouldIntercept =
Expand Down
8 changes: 5 additions & 3 deletions packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>
): DataProvider => {
): DataProviderType => {
const proxy = new Proxy(provider, {
get(_, name) {
return async (...args: any[]) => {
Expand Down
Loading