Skip to content

Commit

Permalink
fix(lib): new hooks types var name
Browse files Browse the repository at this point in the history
  • Loading branch information
SaulMoro committed Apr 26, 2021
1 parent 1a39042 commit 923824d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions projects/ngrx-rtk-query/src/lib/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { MetaReducer } from '@ngrx/store';
import { buildHooks } from './build-hooks';
import { buildMetaReducer } from './build-metareducer';
import { dispatch, getState as getStateFromStore, select } from './thunk.service';
import { QueryHooks, MutationHooks, isQueryDefinition, isMutationDefinition, TS41Hooks } from './types';
import { QueryHooks, MutationHooks, isQueryDefinition, isMutationDefinition, HooksWithUniqueNames } from './types';
import { capitalize, safeAssign } from './utils';

export const angularHooksModuleName = Symbol();
Expand Down Expand Up @@ -52,7 +52,7 @@ declare module '@reduxjs/toolkit/query' {
endpointName: EndpointName,
options?: PrefetchOptions,
): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;
} & TS41Hooks<Definitions> & { metareducer: MetaReducer<any> };
} & HooksWithUniqueNames<Definitions> & { metareducer: MetaReducer<any> };
}
}

Expand Down
4 changes: 3 additions & 1 deletion projects/ngrx-rtk-query/src/lib/types/hooks-ts41-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { EndpointDefinitions, MutationDefinition, QueryDefinition } from '@redux
import { DefinitionType } from '@reduxjs/toolkit/dist/query/endpointDefinitions';
import { UseLazyQuery, UseMutation, UseQuery } from './hooks-types';

export type TS41Hooks<Definitions extends EndpointDefinitions> = keyof Definitions extends infer Keys
// For TS 4.1 and later, we can use string literal types to define
// the exact names of each endpoint's exported hooks
export type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = keyof Definitions extends infer Keys
? Keys extends string
? Definitions[Keys] extends { type: DefinitionType.query }
? {
Expand Down

0 comments on commit 923824d

Please sign in to comment.