[lodash]: memoize.Cache expects construcor (#11707)

https://lodash.com/docs/4.15.0#memoize
This commit is contained in:
Artur Eshenbrener
2016-10-04 21:44:55 +04:00
committed by Mohamed Hegazy
parent dd95604a2f
commit 8922f46b5a
2 changed files with 16 additions and 7 deletions

View File

@@ -5872,12 +5872,18 @@ namespace TestMemoize {
result = _(memoizeFn).chain().memoize(memoizeResolverFn);
}
_.memoize.Cache = {
delete: key => false,
get: key => undefined,
has: key => false,
set(key, value) { return this; }
};
interface MemoizeCache<K, V> {
delete(key: K): boolean;
get(key: K): V;
has(key: K): boolean;
set(key: K, value: V): this;
}
interface MemoizeCacheConstructor {
new (): MemoizeCache<any, any>;
}
let MemoizeCache: MemoizeCacheConstructor
_.memoize.Cache = MemoizeCache;
}
// _.overArgs

5
lodash/lodash.d.ts vendored
View File

@@ -355,6 +355,9 @@ declare module _ {
*/
set(key: string, value: any): _.Dictionary<any>;
}
interface MapCacheConstructor {
new (): MapCache;
}
interface LoDashWrapperBase<T, TWrapper> { }
@@ -10411,7 +10414,7 @@ declare module _ {
*/
memoize: {
<T extends Function>(func: T, resolver?: Function): T & MemoizedFunction;
Cache: MapCache;
Cache: MapCacheConstructor;
}
}