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

Types on onCompleted incomplete, should include undefined #3546

Open
ghost opened this issue Oct 1, 2019 · 0 comments · May be fixed by #3648
Open

Types on onCompleted incomplete, should include undefined #3546

ghost opened this issue Oct 1, 2019 · 0 comments · May be fixed by #3648

Comments

@ghost
Copy link

ghost commented Oct 1, 2019

Intended outcome:

As far as I understand the onCompleted callback is being triggered when a query has finished loading independent of whether there was any data returned or not (e.g. in an error case). This means it is possible to call the callback with data set to undefined.

Therefore the typing should probably be:

onCompleted?: (data: TData | undefined) => void;

Actual outcome:

The current typings are:

onCompleted?: (data: TData) => void;

making it easy to forget handling the undefined-case in the code.

How to reproduce the issue:

n/a I think but would be happy to make something up if people think it's useful.

Version

  System:
    OS: macOS Mojave 10.14.6
  Binaries:
    Node: 12.10.0 - /usr/local/bin/node
    Yarn: 1.16.0 - ~/1-work-projects/app/node_modules/.bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: 69.0.1
    Safari: 13.0.1
  npmPackages:
    @apollo/react-testing: ^3.1.0 => 3.1.0 
    apollo: 2.12.0 => 2.12.0 
    apollo-cache-inmemory: ^1.6.2 => 1.6.2 
    apollo-client: ^2.6.4 => 2.6.4 
    apollo-link: ^1.2.12 => 1.2.12 
    apollo-link-error: ^1.1.11 => 1.1.11 
    apollo-link-http: ^1.5.15 => 1.5.15 
    react-apollo: ^3.1.0 => 3.1.0 
@ghost ghost linked a pull request Oct 30, 2019 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants