-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are typings available? #661
Comments
Last I checked there wasn't any, but I noticed that there's a Even though my long term goal for this library is to move all of it to TypeScript I would love to see a PR with definitions. That way TS users can benefit from it in the meantime. And when work starts on moving the source to TS the library definitions will be a great starting point 😄 |
Yeah I can make the PR no problem, will work on it this week. I'll make it to definitelyTyped for now, just for ease of install. Once the library moves to TS we can migrate here |
Ok cool 👍 |
Hi @quinnlangille, @stipsan Any ETA on this? |
Any update on this? |
Negative, I haven't had time I expected to work on it - however there is an increasing need in office for a solution, so I may get it done soon. If anyone is needed typings now and want them done fast, feel free to take on the task! Just ping here to keep everyone informed |
Here's a workaround that I'm using in the mean time. It assumes you have ioredis and @types/ioredis installed in addition to iosredis-mock. import * as IORedis from 'ioredis';
const MockIORedis = require('ioredis');
const mockRedisClient = new MockIORedis() as IORedis.Redis; |
@stipsan I just saw your comment, I'm working on a PR with definitions but I'd like to ensure some assumptions I've made:
Once I finish the definitions, I have two options:
¿Are my assumptions right? ¿How should I provide you the definitions? |
@stipsan I submitted the PR #849 in order to show you the type definitions. If everything is OK we can merge the definitions or submit a PR to the DefinitelyTyped repo. |
@notaphplover any news on the PR in the DefinitelyTyped repo? |
@CarsonMcKinstry wow I really forgot that, sorry. I've been a bit busy but I think I'll have enough time this weekend. |
@notaphplover Let us know if you need a hand, I'm also interested in this 😄 |
@notaphplover any updates on this? I couldn't find the PR on the DefinitelyTyped repository. :'( |
@steveklebanoff aren't you basically just creating an instance of import RedisMock from 'ioredis-mock';
import { Redis as IORedis } from 'ioredis';
const Redis = RedisMock as IORedis; Doesn't work
import RedisMock from 'ioredis-mock';
import * as IORedis from 'ioredis';
const Redis = RedisMock as IORedis; Doesn't work because
Same goes for import RedisMock from 'ioredis-mock';
import * as IORedis from 'ioredis';
import * as IORedisMock from 'ioredis-mock';
const TempIORedis = IORedisMock as unknown;
const Redis = TempIORedis as IORedis; |
This seems to work for me as a workaround: import * as IORedis from 'ioredis'
const IoRedisMock: typeof IORedis = require('ioredis-mock') |
@arctouch-gabrielluchtenberg @havsar You can use the IORedis types, but the mock doesn't fully cover it / has some differences, which are documented, so your types will be wrong and lead to some hard to identify issues. |
@notaphplover Do you have any news for this? Cheers. |
@Theo-Evrard I'm so sorry, the definition file is in this PR, feel free to do the PR to DefinitelyTyped. It's been a while and some definitions probably needs an update, but I would hazard to say it's better than having no types. I've been wondering if maybe types should be included in this repo:
I know it's the opposite I said previously, but now I think it's the best way. I'm sorry for half and a year of silence, I have no excuses at all (even if it's true I've been busy) |
Hey, so there's the data property available on the redis-mock options but it isn't available on |
updates: it's available on npm now, you can just use I create a PR at DefinitelyTyped but it's not merged yet. DefinitelyTyped/DefinitelyTyped#63499 You can add this snippet to your project
declare module 'ioredis-mock' {
import ioredis = require('ioredis');
type RedisOptions = { data?: Record<string, unknown> } & ioredis.RedisOptions;
interface Constructor {
new (port: number, host: string, options: RedisOptions): ioredis.Redis;
new (path: string, options: RedisOptions): ioredis.Redis;
new (port: number, options: RedisOptions): ioredis.Redis;
new (port: number, host: string): ioredis.Redis;
new (options: RedisOptions): ioredis.Redis;
new (port: number): ioredis.Redis;
new (path: string): ioredis.Redis;
new (): ioredis.Redis;
}
const redisMock: Constructor;
export default redisMock;
} |
I'm trying to use this package in a typescript application but can't find type declarations anywhere. Just making sure they don't exist before I create some.
The text was updated successfully, but these errors were encountered: