diff --git a/lodash/lodash-3.10-tests.ts b/lodash/lodash-3.10-tests.ts index 683821044b..0a2debfa00 100644 --- a/lodash/lodash-3.10-tests.ts +++ b/lodash/lodash-3.10-tests.ts @@ -6162,20 +6162,42 @@ namespace TestFlowRight { // _.memoize namespace TestMemoize { - var testMemoizedFunction: _.MemoizedFunction; - var cache = <_.MapCache>testMemoizedFunction.cache; - interface TestMemoizedResultFn extends _.MemoizedFunction { + { + let memoizedFunction: _.MemoizedFunction; + let cache: _.MapCache = memoizedFunction.cache; + } + + interface MemoizedResultFn extends _.MemoizedFunction { (a1: string, a2: number): boolean; } - var testMemoizeFn = (a1: string, a2: number) => a1.length > a2; - var testMemoizeResolverFn = (a1: string, a2: number) => a1 + a2; - var result: TestMemoizedResultFn; - result = _.memoize(testMemoizeFn); - result = _.memoize(testMemoizeFn, testMemoizeResolverFn); - result = _(testMemoizeFn).memoize().value(); - result = _(testMemoizeFn).memoize(testMemoizeResolverFn).value(); - result('foo', 1); - result.cache.get('foo1'); + + let memoizeFn: (a1: string, a2: number) => boolean; + let memoizeResolverFn: (a1: string, a2: number) => string; + + { + let result: MemoizedResultFn; + + result = _.memoize(memoizeFn); + result = _.memoize(memoizeFn, memoizeResolverFn); + + result('foo', 1); + result.cache.get('foo1'); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(memoizeFn).memoize(); + result = _(memoizeFn).memoize(memoizeResolverFn); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(memoizeFn).chain().memoize(); + result = _(memoizeFn).chain().memoize(memoizeResolverFn); + } + _.memoize.Cache = { delete: key => false, get: key => undefined, diff --git a/lodash/lodash-3.10.d.ts b/lodash/lodash-3.10.d.ts index cb0e0b45c7..b92de15c89 100644 --- a/lodash/lodash-3.10.d.ts +++ b/lodash/lodash-3.10.d.ts @@ -9820,6 +9820,7 @@ declare module _ { * storing the result based on the arguments provided to the memoized function. By default, the first argument * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with * the this binding of the memoized function. + * * @param func The function to have its output memoized. * @param resolver The function to resolve the cache key. * @return Returns the new memoizing function. @@ -9837,6 +9838,13 @@ declare module _ { memoize(resolver?: Function): LoDashImplicitObjectWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.memoize + */ + memoize(resolver?: Function): LoDashExplicitObjectWrapper; + } + //_.modArgs interface LoDashStatic { /** diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 19af6c147f..7931acb2b2 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -6066,20 +6066,42 @@ namespace TestFlowRight { // _.memoize namespace TestMemoize { - var testMemoizedFunction: _.MemoizedFunction; - var cache = <_.MapCache>testMemoizedFunction.cache; - interface TestMemoizedResultFn extends _.MemoizedFunction { + { + let memoizedFunction: _.MemoizedFunction; + let cache: _.MapCache = memoizedFunction.cache; + } + + interface MemoizedResultFn extends _.MemoizedFunction { (a1: string, a2: number): boolean; } - var testMemoizeFn = (a1: string, a2: number) => a1.length > a2; - var testMemoizeResolverFn = (a1: string, a2: number) => a1 + a2; - var result: TestMemoizedResultFn; - result = _.memoize(testMemoizeFn); - result = _.memoize(testMemoizeFn, testMemoizeResolverFn); - result = _(testMemoizeFn).memoize().value(); - result = _(testMemoizeFn).memoize(testMemoizeResolverFn).value(); - result('foo', 1); - result.cache.get('foo1'); + + let memoizeFn: (a1: string, a2: number) => boolean; + let memoizeResolverFn: (a1: string, a2: number) => string; + + { + let result: MemoizedResultFn; + + result = _.memoize(memoizeFn); + result = _.memoize(memoizeFn, memoizeResolverFn); + + result('foo', 1); + result.cache.get('foo1'); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(memoizeFn).memoize(); + result = _(memoizeFn).memoize(memoizeResolverFn); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(memoizeFn).chain().memoize(); + result = _(memoizeFn).chain().memoize(memoizeResolverFn); + } + _.memoize.Cache = { delete: key => false, get: key => undefined, diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 329c759e8b..bd996b9638 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -10545,6 +10545,7 @@ declare module _ { * storing the result based on the arguments provided to the memoized function. By default, the first argument * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with * the this binding of the memoized function. + * * @param func The function to have its output memoized. * @param resolver The function to resolve the cache key. * @return Returns the new memoizing function. @@ -10562,6 +10563,13 @@ declare module _ { memoize(resolver?: Function): LoDashImplicitObjectWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.memoize + */ + memoize(resolver?: Function): LoDashExplicitObjectWrapper; + } + //_.overArgs (was _.modArgs) interface LoDashStatic { /**