From 440ac39ec2d3d3721b1d79e9b8c94824c398add2 Mon Sep 17 00:00:00 2001 From: Cameron Knight Date: Wed, 17 Apr 2019 15:53:08 -0700 Subject: [PATCH 1/2] Use ReadonlyArray instead of Array on input args The runtime code does not alter the Arrays in question, and it is good form to prefer `ReadonlyArray` over `Array` (aka `T[]`) in the input position when one can. --- src/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 68fae7a..f874ee1 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -37,7 +37,7 @@ declare class DataLoader { * ]); * */ - loadMany(keys: K[]): Promise; + loadMany(keys: ReadonlyArray): Promise; /** * Clears the value at `key` from the cache, if it exists. Returns itself for @@ -70,7 +70,7 @@ declare namespace DataLoader { // A Function, which when given an Array of keys, returns a Promise of an Array // of values or Errors. - export type BatchLoadFn = (keys: K[]) => Promise>; + export type BatchLoadFn = (keys: ReadonlyArray) => Promise>; // Optionally turn off batching or caching or provide a cache key function or a // custom cache instance. From d0374ec0142b6f802e6e48a46313246ff96cada7 Mon Sep 17 00:00:00 2001 From: Lee Byron Date: Wed, 13 Nov 2019 10:25:01 -0800 Subject: [PATCH 2/2] Use ReadonlyArray in promise result --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 6540fc7..da9cab0 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -71,7 +71,7 @@ declare namespace DataLoader { // A Function, which when given an Array of keys, returns a Promise of an Array // of values or Errors. export type BatchLoadFn = - (keys: ReadonlyArray) => PromiseLike>; + (keys: ReadonlyArray) => PromiseLike>; // Optionally turn off batching or caching or provide a cache key function or a // custom cache instance.