Skip to content

redis client #private type error #266

@ladderschool

Description

@ladderschool

My installed packages:

    "redis": "4.7.0",
    "redis-om": "0.4.7",
    "@redis/client": "1.6.0",
    "@redis/graph": "1.1.1",
    "@redis/json": "1.0.7",
    "@redis/search": "1.2.0",

My code:

import { createClient } from 'redis'

export const createRedisClient = (db = 0) => {
  const client = createClient({
    url: process.env.REDIS_URL,
  })

  client.on('connect', () => {
    client.select(db)
  })

  return client
}

export const redis = createRedisClient()

// Then I use this to create a redis-om repository:
redis.connect()

export const connectionsRepository = new Repository(connectionSchema, redis)

The redis client shows a typescript error:

Argument of type 'RedisClientType<{ graph: { CONFIG_GET: typeof import("<path>/node_modules/@redis/graph/dist/commands/CONFIG_GET"); configGet: typeof import("<path>/node_modules/@redis/graph/dist/commands/CONFIG_GET"); ... 15 more ...; slowLog: typeof import("<path>...' is not assignable to parameter of type 'Client | RedisConnection'.
index.d.ts(92, 5): '#private' is declared here.

If I import the createClient from '@redis/client' I get a similar error:

Argument of type 'RedisClientType<RedisModules, RedisFunctions, RedisScripts>' is not assignable to parameter of type 'Client | RedisConnection'.
  Type 'RedisClientType<RedisModules, RedisFunctions, RedisScripts>' is not assignable to type 'RedisClientType<{ graph: { CONFIG_GET: typeof ...

Here's my tsconfig.json:

{
  "compilerOptions": {
    "noEmit": true,
    "allowJs": true,
    "esModuleInterop": true,
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions