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

Provide type extension to make apolloClient parameter type-safe #120

Open
oosawy opened this issue Jul 18, 2024 · 0 comments
Open

Provide type extension to make apolloClient parameter type-safe #120

oosawy opened this issue Jul 18, 2024 · 0 comments

Comments

@oosawy
Copy link

oosawy commented Jul 18, 2024

As done in manager.ts, the ambient module declaration can be used be extend Storybook's Parameters type to include apolloClient and its type. But the declaration doesn't appear in the compiled code.

declare module "@storybook/react" {
interface Parameters extends ApolloParameters {}
}

It would be nice if it works type-safe out of the box, but TypeScript only loads types if it imported or the package is @types/* AFAIK.

So I'm thinking about add a new entry point like storybook-types providing the declarations, and letting the user import it to get full type-safety.

Another option: Tell users to add the following code to something.d.ts in README

import { MockedProviderProps } from "@apollo/client/testing";

declare module '@storybook/types' {
  interface Parameters {
    apolloClient?: Partial<Omit<MockedProviderProps, "children">>;
  }
}
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

1 participant