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

[cache-inmemory] Not all code paths return a value #4126

Closed
dumaron opened this issue Nov 9, 2018 · 3 comments
Closed

[cache-inmemory] Not all code paths return a value #4126

dumaron opened this issue Nov 9, 2018 · 3 comments

Comments

@dumaron
Copy link
Contributor

dumaron commented Nov 9, 2018

With my last npm update apollo-cache-inmemory prevent typescript compilation of my project. The problem is that in 3 functions there isn't a default return. This code will work even without those returns, but I think that this typescript check is not unreasonable and the code can be fixed with a little effort.

This is one of the three error I get:

/home/duma/dev/fooddata-ifn/node_modules/apollo-cache-inmemory/src/queryKeyMaker.ts
(69,33): Not all code paths return a value.

If we look at the code, it is evident that adding a return false between the last two lines of code will fix the problem:

this.query.definitions.some(definition => {
      if (definition.kind === "FragmentDefinition" &&
          definition.name.value === name) {
        fragment = definition;
        return true;
      }
});

The same is true for readFromStore.ts with the functions on line 113 and 118.

Am I right? There's something I'm missing about this?

Versions

System:
    OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
  Binaries:
    Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
    Yarn: 1.12.3 - /usr/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm
  Browsers:
    Chrome: 70.0.3538.77
    Firefox: 63.0
  npmPackages:
    apollo-cache-inmemory: ^1.3.9 => 1.3.9 
    apollo-client: ^2.4.5 => 2.4.5 
    apollo-fetch: ^0.7.0 => 0.7.0 
    apollo-link: ^1.2.2 => 1.2.3 
    apollo-link-http: ^1.5.5 => 1.5.5 
    react-apollo: ^2.1.11 => 2.2.4 
@benjamn
Copy link
Member

benjamn commented Nov 13, 2018

Happy to take a PR to fix this, though of course the current code works in any JS environment.

@dumaron
Copy link
Contributor Author

dumaron commented Nov 13, 2018

Hi @benjamn , I've make this PR a few minutes ago... hope it helps!

@CarloPalinckx
Copy link
Contributor

@dumaron this issue seems to be resolved by #4137. Would you be so kind to close this issue if this is no longer a problem?

@dumaron dumaron closed this as completed Jan 4, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
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

3 participants