Skip to content

TS2322: Type 'Redis' is not assignable to type 'RedisClient'. #559

@foxcartlab

Description

@foxcartlab

my redis-pub-sub.provider.ts like below ;

import { pubSubToken } from '@nestjs-query/query-graphql';
import { RedisPubSub } from 'graphql-redis-subscriptions';
import Redis from 'ioredis';
import { Provider } from '@nestjs/common';

export class RedisPubSubProvider {
  static provider(): Provider {
    return {
      provide: pubSubToken(),
      useFactory: () => {
        const options = {
          host: process.env.REDIS_HOST || 'localhost',
          port: 6379
        };
        return new RedisPubSub({
          publisher: new Redis(options),
          subscriber: new Redis(options)
        })
      } ,
    };
  }
}

and error like ;

[build 7/7] RUN npx nx build driver-api --prod:
#12 6.275
#12 6.276 > nx run driver-api:build:production
#12 6.276
#12 50.06 chunk (runtime: main) main.js (main) 348 KiB [entry] [rendered]
#12 50.06
#12 50.06 ERROR in /app/libs/database/src/lib/redis-pub-sub.provider.ts
#12 50.06 ./libs/database/src/lib/redis-pub-sub.provider.ts 16:10-19
#12 50.06 [tsl] ERROR in /app/libs/database/src/lib/redis-pub-sub.provider.ts(16,11)
#12 50.06 TS2322: Type 'Redis' is not assignable to type 'RedisClient'.
#12 50.06 Type 'Redis' is missing the following properties from type 'Redis': stream, isCluster, connector, reconnectTimeout, and 140 more.
#12 50.06
#12 50.06 ERROR in /app/libs/database/src/lib/redis-pub-sub.provider.ts
#12 50.06 ./libs/database/src/lib/redis-pub-sub.provider.ts 17:10-20
#12 50.06 [tsl] ERROR in /app/libs/database/src/lib/redis-pub-sub.provider.ts(17,11)
#12 50.06 TS2322: Type 'Redis' is not assignable to type 'RedisClient'.
#12 50.06
#12 50.06 ERROR in libs/database/src/lib/redis-pub-sub.provider.ts:16:11
#12 50.06 TS2322: Type 'Redis' is not assignable to type 'RedisClient'.
#12 50.06 Type 'Redis' is missing the following properties from type 'Redis': stream, isCluster, connector, reconnectTimeout, and 140 more.
#12 50.06 14 | };
#12 50.06 15 | return new RedisPubSub({
#12 50.06 > 16 | publisher: new Redis(options),
#12 50.06 | ^^^^^^^^^
#12 50.06 17 | subscriber: new Redis(options)
#12 50.06 18 | })
#12 50.06 19 | } ,
#12 50.06
#12 50.06 ERROR in libs/database/src/lib/redis-pub-sub.provider.ts:17:11
#12 50.06 TS2322: Type 'Redis' is not assignable to type 'RedisClient'.
#12 50.06 15 | return new RedisPubSub({
#12 50.06 16 | publisher: new Redis(options),
#12 50.06 > 17 | subscriber: new Redis(options)
#12 50.06 | ^^^^^^^^^^
#12 50.06 18 | })
#12 50.06 19 | } ,
#12 50.06 20 | };
#12 50.06
#12 50.06 webpack compiled with 4 errors (bc25c10f78b686c1)
#12 50.16
#12 50.16
#12 50.16
#12 50.16 > NX Running target "driver-api:build" failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions