question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ioredis v5 typescript error

See original GitHub issue

Hi, I’m using ioredis, upstash and I’ve updated to latest version. My typescript is flagging the instance line with an error: No overload matches this call.

import Redis from 'ioredis';
const redis = new Redis(process.env.REDIS_CONNECTION_STRING);
export default redis;

where REDIS_CONNECTION_STRING is following the example on upstash and rediss://:PASSWORD@REGION-DOMAIN.upstash.io:PORT

I know this is probably an issue with upstash, but can I update my instance to

import Redis from 'ioredis';
const redis = new Redis(PORT, process.env.REDIS_CONNECTION_STRING_WITHOUT_PORT);
export default redis;

Is this the newest way?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
luincommented, Apr 11, 2022

It has to be in uppercase, which is EX. There is a migration guide on the README that mentions this.

1reaction
luincommented, Apr 11, 2022

process.env.REDIS_CONNECTION_STRING may be undefined, which will make the statement look like:

const redis = new Redis(undefined)

And there is no overload for this.

import Redis from "ioredis";

if (!process.env.REDIS_CONNECTION_STRING) {
  throw new Error("Missing REDIS_CONNECTION_STRING");
}
const redis = new Redis(process.env.REDIS_CONNECTION_STRING);

export default redis;

Adding an assert fixes the issue.

Having said that seems we can add the support for new Redis(undefined) to make everything default. WDYT?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors from ioredis when compiling typescript code · Issue #1566
When running the tsc command ioredis gives a lot of errors when compiling typescript code. Versions used ioredis -5.0.4 Nodejs - 16.14.0 ...
Read more >
ioredis - npm
A robust, performance-focused and full-featured Redis client for Node.js.. Latest version: 5.2.4, last published: 2 months ago.
Read more >
issues after upgrading ioredis to v5.0.1 - Stack Overflow
I'm getting a semantic error when I compile the project typescript. xxx/node_modules/@types/connect-redis/index.d.ts(22,51): ...
Read more >
IORedis | Ts.ED - A Node.js and TypeScript Framework on top ...
Support classic Redis connection and Cluster connection. Inject connection to another service. Mock connection for unit/integration test. # Installation. npm ...
Read more >
Redis with Node.js (ioredis) | Redis Documentation Center
This example shows how to configure ioredis to make a connection to Redis using TLS ... [ioredis] Unhandled error event: ReplyError: NOPERM this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found