From b7f644036d8fbb9bf358aff970825b6906184da6 Mon Sep 17 00:00:00 2001 From: Adam Herrmann Date: Thu, 26 Apr 2018 15:06:05 -0400 Subject: [PATCH] Allow specific CacheMap key type --- src/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index aa40aac..7a5ca66 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -15,9 +15,9 @@ * with different access permissions and consider creating a new instance * per web request. */ -declare class DataLoader { +declare class DataLoader { - constructor(batchLoadFn: DataLoader.BatchLoadFn, options?: DataLoader.Options); + constructor(batchLoadFn: DataLoader.BatchLoadFn, options?: DataLoader.Options); /** * Loads a key, returning a `Promise` for the value represented by that key. @@ -61,10 +61,10 @@ declare class DataLoader { declare namespace DataLoader { // If a custom cache is provided, it must be of this type (a subset of ES6 Map). - export type CacheMap = { - get(key: K): V | void; - set(key: K, value: V): any; - delete(key: K): any; + export type CacheMap = { + get(key: C): V | void; + set(key: C, value: V): any; + delete(key: C): any; clear(): any; } @@ -74,7 +74,7 @@ declare namespace DataLoader { // Optionally turn off batching or caching or provide a cache key function or a // custom cache instance. - export type Options = { + export type Options = { /** * Default `true`. Set to `false` to disable batching, @@ -102,14 +102,14 @@ declare namespace DataLoader { * objects are keys and two similarly shaped objects should * be considered equivalent. */ - cacheKeyFn?: (key: any) => any, + cacheKeyFn?: (key: K) => C, /** * An instance of Map (or an object with a similar API) to * be used as the underlying cache for this loader. * Default `new Map()`. */ - cacheMap?: CacheMap>; + cacheMap?: CacheMap>; } }