Skip to content

Commit

Permalink
feat(main-loader): improve Key generic definition
Browse files Browse the repository at this point in the history
  • Loading branch information
fooddilsn committed Feb 17, 2023
1 parent e9e5e2e commit 2c99105
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/main-loader/lib/create-queries-map-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { updateKeyLimit } from './update-key-limit';
import { updateKeySkip } from './update-key-skip';

export const createQueriesMapFactory =
<Q extends object>() =>
<Q extends Record<string, unknown>>() =>
(keys: readonly Key<Q>[]) => {
const queriesMap = new Map<string, Key<Q>>();
for (const key of keys) {
Expand Down
2 changes: 1 addition & 1 deletion packages/main-loader/lib/key.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Projection } from './projection';

export interface Key<Q extends object> {
export interface Key<Q extends Record<string, unknown>> {
query: Q;
projection: Projection;
skip?: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/main-loader/lib/main-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { hash } from './hash';
import type { Key } from './key';
import { createQueriesMapFactory } from './create-queries-map-factory';

export abstract class MainLoader<T, Q extends object> {
export abstract class MainLoader<T, Q extends Record<string, unknown>> {
protected loader: DataLoader<Key<Q>, T>;

constructor() {
Expand Down
2 changes: 1 addition & 1 deletion packages/main-loader/lib/update-key-limit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Key } from './key';

export function updateKeyLimit<Q extends object>(previous: Key<Q>, current: Key<Q>) {
export function updateKeyLimit<Q extends Record<string, unknown>>(previous: Key<Q>, current: Key<Q>) {
if (!(previous.limit && current.limit) || previous.limit === 0 || current.limit === 0) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/main-loader/lib/update-key-skip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Key } from './key';

export function updateKeySkip<Q extends object>(previous: Key<Q>, current: Key<Q>) {
export function updateKeySkip<Q extends Record<string, unknown>>(previous: Key<Q>, current: Key<Q>) {
if (!(previous.skip && current.skip) || previous.skip === 0 || current.skip === 0) {
return 0;
}
Expand Down

0 comments on commit 2c99105

Please sign in to comment.