Skip to content

Property 'on' does not exist on type 'RedisClientType' #2067

@ngr900

Description

@ngr900

I'm following the "Basic Example" from the README:

import { createClient } from 'redis';
(async () => {
  const client = createClient();

  client.on('error', (err) => console.log('Redis Client Error', err));

  await client.connect();

  await client.set('key', 'value');
  const value = await client.get('key');
})();

This results in the following TypeScript error:

Property 'on' does not exist on type 'RedisClientType<{ graph: { CONFIG_GET: typeof import("..."); configGet: typeof import("..."); ... 15 more ...; slowLog: typeof import("...'.ts(2339)

The property is there:

console.log((client as any).on); // logs: [Function: addListener]

It just appears to not be included in the type.

Environment:

  • Node.js Version: v14.17.5
  • Redis Server Version: 6.2.6
  • Node Redis Version: redis@4.0.6
  • Platform: Windows 11 22000.556 + WSL Ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions