Skip to content

Commit

Permalink
RedisAdapter typing shadowed this
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Zelaya authored and Nicolas Zelaya committed Nov 6, 2023
1 parent 6268360 commit 965df61
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/storages/inRedis/RedisAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ioredis from 'ioredis';
import ioredis, { Pipeline } from 'ioredis';
import { ILogger } from '../../logger/types';
import { merge, isString } from '../../utils/lang';
import { _Set, setToArray, ISet } from '../../utils/lang/sets';
Expand Down Expand Up @@ -89,12 +89,15 @@ export class RedisAdapter extends ioredis {
};

const wrapCommand = (originalMethod: Function, methodName: string) => {
// The value of "this" in this function should be the instance actually executing the method. It might be the instance referred (the base one)
// or it can be the instance of a Pipeline object.
return function () {
const params = arguments;
const caller: (Pipeline | RedisAdapter) = this; // Need to change this crap to have TypeScript stop complaining

Check failure on line 96 in src/storages/inRedis/RedisAdapter.ts

View workflow job for this annotation

GitHub Actions / Build

'this' implicitly has type 'any' because it does not have a type annotation.

const commandWrapper = () => {
instance.log.debug(`${LOG_PREFIX} Executing ${methodName}.`);
const result = originalMethod.apply(this, params);
const result = originalMethod.apply(caller, params);

if (thenable(result)) {
// For handling pending commands on disconnect, add to the set and remove once finished.
Expand Down

0 comments on commit 965df61

Please sign in to comment.