microlinkhq / keyvhq

Simple key-value storage with support for multiple backends.

Home Page:https://keyvhq.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to create a KeyvRedis with an existing Redis instance in Typescript

talzion12 opened this issue · comments

In the readme for keyv redis it says that a KeyvRedis can be constructed as follows:

const KeyvRedis = require('@keyvhq/redis')
const Keyv = require('@keyvhq/core')
const Redis = require('ioredis')

const redis = new Redis('redis://user:pass@localhost:6379')
const keyv = new Keyv({ store: new KeyvRedis(redis) })

However this code doesn't compile with Typescript, nor should it according to index.d.ts.

Looking at the JS I think the code does work although I didn't test this. IMO the only change that is needed is to add a constructor to the index.d.ts file. In fact there seem to be 2 identical constructors in index.d.ts, I assume one of them was supposed to be the constructor to create a KeyvRedis with a Redis instance.

Thanks for reporting; Can you make a PR for this? 🙂

Sure.