Skip to content

Commit 82d979d

Browse files
ebceu4jaredwray
andauthored
preserve args type when wrapping (#943)
* preserve args type when wrapping * fixing lint errors --------- Co-authored-by: Jared Wray <me@jaredwray.com>
1 parent 34f13d7 commit 82d979d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/cacheable/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ export class Cacheable extends Hookified {
576576
* @param {WrapOptions} [options] The options for the wrap function
577577
* @returns {Function} The wrapped function
578578
*/
579-
public wrap<T>(function_: (...arguments_: any[]) => T, options?: WrapFunctionOptions): (...arguments_: any[]) => T {
579+
public wrap<T, Arguments extends any[]>(function_: (...arguments_: Arguments) => T, options?: WrapFunctionOptions): (...arguments_: Arguments) => T {
580580
const wrapOptions = {
581581
ttl: options?.ttl ?? this._ttl,
582582
keyPrefix: options?.keyPrefix,

packages/cacheable/src/memory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ export class CacheableMemory extends Hookified {
598598
* @param {Object} [options] - The options to wrap
599599
* @returns {Function} - The wrapped function
600600
*/
601-
public wrap<T>(function_: (...arguments_: any[]) => T, options?: WrapFunctionOptions): (...arguments_: any[]) => T {
601+
public wrap<T, Arguments extends any[]>(function_: (...arguments_: Arguments) => T, options?: WrapFunctionOptions): (...arguments_: Arguments) => T {
602602
const wrapOptions = {
603603
ttl: options?.ttl ?? this._ttl,
604604
keyPrefix: options?.keyPrefix,

0 commit comments

Comments
 (0)