Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

2.0.0 typescript error in Apollo Provider, missing method in interface #1299

Closed
jbiros91 opened this issue Oct 28, 2017 · 5 comments
Closed

Comments

@jbiros91
Copy link

Intended outcome:
Upgrading from 1.x release to the 2.x release.

Actual outcome:
Types of property 'client' are incompatible.
Type 'ApolloClient<NormalizedCache>' is not assignable to type 'ApolloClient<Cache>'.
Type 'NormalizedCache' is not assignable to type 'Cache'.
Property 'add' is missing in type 'NormalizedCache'.

How to reproduce the issue:
Install react apollo in a typescript project and run tsc

Version

  • apollo-client@<2.0.1>
  • react-apollo@<2.0.0>
@corydeppen
Copy link
Contributor

Rather than using the Cache type, which is defined in the TypeScript lib.dom.d.ts declaration file, for the generic parameter to ProviderProps in the ApolloProvider class, it may be more appropriate to use any to let the type flow through when the client is created. It may also be less confusing if the generic type parameter was renamed to something like TCache in the ProviderProps interface definition so it's not confused with the Cache type.

I tested this change in the ApolloProvider.d.ts file and noticed the error went away and the client was properly typed as NormalizedCache when defining the cache as InMemoryCache.

@amborle
Copy link

amborle commented Oct 30, 2017

@corydeppen thanks, this worked! Can you make a pull request?

@Jannis
Copy link

Jannis commented Nov 2, 2017

Who's in charge of deciding how this gets fixed? I'm also hitting this with

    "apollo-cache-inmemory": "^1.0.0",
    "apollo-client": "^2.0.1",
    "apollo-link-http": "^1.1.0",
    "apollo-link-state": "^0.0.4",
    "graphql": "^0.11.7",
    "graphql-tag": "^2.5.0",
    "react-apollo": "2.0.0",

@stale
Copy link

stale bot commented Nov 23, 2017

This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!

@stale
Copy link

stale bot commented Dec 7, 2017

This issue has been automatically closed because it has not had recent activity after being marked as no recent activyt. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to React Apollo!

@stale stale bot closed this as completed Dec 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants