From 6448efea6b05d28d3f77f36c7c9e161af18788ea Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 31 Oct 2018 16:40:37 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20support=20WeakMap=E2=80=99s=20in=20loda?= =?UTF-8?q?sh=20memoize.Cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/lodash/common/common.d.ts | 8 ++++---- types/lodash/lodash-tests.ts | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/types/lodash/common/common.d.ts b/types/lodash/common/common.d.ts index 864450b1bd..554fe76668 100644 --- a/types/lodash/common/common.d.ts +++ b/types/lodash/common/common.d.ts @@ -127,21 +127,21 @@ declare module "../index" { * @param key The key of the value to remove. * @return Returns `true` if the entry was removed successfully, else `false`. */ - delete(key: string): boolean; + delete(key: any): boolean; /** * Gets the cached value for `key`. * @param key The key of the value to get. * @return Returns the cached value. */ - get(key: string): any; + get(key: any): any; /** * Checks if a cached value for `key` exists. * @param key The key of the entry to check. * @return Returns `true` if an entry for `key` exists, else `false`. */ - has(key: string): boolean; + has(key: any): boolean; /** * Sets `value` to `key` of the cache. @@ -154,7 +154,7 @@ declare module "../index" { /** * Removes all key-value entries from the map. */ - clear(): void; + clear?: () => void; } interface MapCacheConstructor { new (): MapCache; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 0515136714..3ce044165a 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -3484,6 +3484,11 @@ fp.now(); // $ExpectType number // $ExpectType MapCache new _.memoize.Cache(); + _.memoize.Cache = WeakMap; + _.memoize.Cache = Map; + const memoizedFn = _.memoize(memoizeFn); + memoizedFn.cache = new WeakMap(); + memoizedFn.cache = new Map(); } // _.overArgs