Skip to content
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

Named export #1551

Closed
fabrykowski opened this issue Mar 29, 2022 · 5 comments
Closed

Named export #1551

fabrykowski opened this issue Mar 29, 2022 · 5 comments

Comments

@fabrykowski
Copy link
Contributor

The new version (v5) comes with built-in typings, which I find great!
@types/ioredis has, however, a named export, whereas ioredis only a default one.

Would you consider adding a named export to your type definition, so that existing code with

import { Redis } from 'ioredis';

does not break?

@luin
Copy link
Collaborator

luin commented Mar 30, 2022

Hey @fabrykowski 👋

Thanks for the feedback! After a search, I think import * as Redis from 'ioredis' has more usages than import { Redis } from 'ioredis' and I feel supporting both import styles may confuse users.

For now, given it's should be easy for projects to migrate, I'd just go with import Redis from 'ioredis' unless there are crucial reasons. WDYT?

@fabrykowski
Copy link
Contributor Author

The breaking change is, that in @types/ioredis the default export is a namespace, meaning that to get the type of the client you previously had two choices:

import * as Redis from 'ioredis';
// or equivalently
// import Redis from 'ioredis';

type RedisClient = Redis.Redis;

or

import { Redis } from 'ioredis';

type RedisClient = Redis;

In v5 the only way is

import Redis from 'ioredis';

type RedisClient = Redis;

Of course a new major version is not required to be backwards compatible, but adding the named export would allow other libraries (e.g. graphql-redis-subscriptions) to support both versions simultaneously, which would help adopt the new major version.

@luin
Copy link
Collaborator

luin commented Mar 30, 2022

Alright. That's a fair enough point. I think we should only export the type to avoid confusion then:

export type { default as Redis } from "./Redis";

Is this enough to allow graphql-redis-subscriptions to support both versions simultaneously? Just don't want to give multiple choices for users to import the same thing.

@fabrykowski
Copy link
Contributor Author

fabrykowski commented Mar 30, 2022

Sure! I'll update the PR.

Thank you!

@luin
Copy link
Collaborator

luin commented Mar 31, 2022

Closing via #1552

@luin luin closed this as completed Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants