What is the error Type or Interface in ioredis?

38 views Asked by At

I use ioredis and have this snippet:

import Redis from 'ioredis';

const client = new Redis({
  port: 13225,
  host: 'xxx',
  username: 'default',
  password: 'xxx',
  tls: {
    rejectUnauthorized: false
  }
});


client.on('error', error => {
  if (error.code === 'ECONNRESET') {
    //console.log('Connection to Redis Session Store timed out.');
  } else if (error.code === 'ECONNREFUSED') {
   // console.log('Connection to Redis Session Store refused!');
  } else console.log(error);
});

You see error.code I got typescript error:

Property 'code' does not exist on type 'Error'

I cant find an error interface or type in ioredis. How can I solve the problem above ?

ps: I am new at typescript

0

There are 0 answers