Skip to content

Commit

Permalink
refactor(cache): use Record<string, any> as the default Entity type
Browse files Browse the repository at this point in the history
Use a more appropriate real-life default type for `cache.modify`.
  • Loading branch information
Gelio committed Jun 2, 2023
1 parent c845531 commit 3681939
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cache/core/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
return [];
}

public modify<Entity = any>(options: Cache.ModifyOptions<Entity>): boolean {
public modify<Entity = Record<string, any>>(options: Cache.ModifyOptions<Entity>): boolean {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cache/core/types/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export namespace Cache {
discardWatches?: boolean;
}

export interface ModifyOptions<Entity = any> {
export interface ModifyOptions<Entity = Record<string, any>> {
id?: string;
fields: Entity extends Record<string, unknown>
? Modifiers<Entity> | Modifier<Entity>
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
}
}

public modify<Entity = any>(options: Cache.ModifyOptions<Entity>): boolean {
public modify<Entity = Record<string, any>>(options: Cache.ModifyOptions<Entity>): boolean {
if (hasOwn.call(options, "id") && !options.id) {
// To my knowledge, TypeScript does not currently provide a way to
// enforce that an optional property?:type must *not* be undefined
Expand Down

0 comments on commit 3681939

Please sign in to comment.