Open
Description
Description
Run the example code:
import { createClient, RedisClientOptions } from 'redis';
const options: RedisClientOptions = {};
const client = await createClient(options)
.on('error', err => console.log('Redis Client Error', err))
.connect();
const value = await client.HGET('hash', 'key');
console.log(value);
await client.disconnect();
It prints null
if hash
doesn't exist on the server. However, TypeScript says:
┌─────────────────────────────────────────────────┐
│const value: string | undefined │
└─────────────────────────────────────────────────┘
Which is wrong. TypeScript should remind the caller it should handle null.
Node.js Version
20.12.2
Redis Server Version
7.0.7 (Amazon ElastiCache)
Node Redis Version
4.7.0
Platform
Linux
Logs
No response