Nest InjectRedis incompatible with typescript 5.1.6

190 Views Asked by At

I have updated my typescript version from 4.9.5 to 5.1.6 in my NestJs project and @InjectRedis no longer works

This is the code:

@Injectable() export class MyService { constructor( @InjectRedis('REDIS') private readonly redisService: Redis, ) {} ... }

The error I receive is: "Unable to resolve signature of parameter decorator when called as an expression.
Argument of type 'undefined' is not assignable to parameter of type 'string | symbol'."

Maybe someone has an idea on how to fix it?

I really have no idea where to start to fix it.

2

There are 2 best solutions below

2
Micael Levi On

That limitation was fixed on @nestjs/common v9.3.0

Make sure you have you're using the latest version (or at least the latest of NestJS v9) of all your @nestjs/* packages

0
Daniel On

I have not been able to find a clean solution for this. But I have created this issue https://github.com/nest-modules/ioredis/issues/267.

However, a workaround may be @(InjectRedis as any)('REDIS') instead of @InjectRedis('REDIS').