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

Types on onCompleted incomplete, should include undefined #3546

Open
@ghost

Description

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions