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

Improve types in Query component. Make data be undefined in initial load #1581

Merged
merged 1 commit into from Jan 25, 2018

Conversation

Projects
None yet
3 participants
@leoasis
Copy link
Collaborator

leoasis commented Jan 25, 2018

This PR improves the types of Query for Typescript a bit. It adds variables as a parameter type, defaulting to an object of whatever. Also makes the data reflect the fact that it may not have information yet (in the initial load for example). Since it's better to check for null than for an empty object, I figured I'd change the API a bit and make data be either TData or undefined. Typescript works better in this case since it will refine the type after checking for its truthiness. Also I think it makes more sense than returning an empty object, since the null exception is going to be delayed until you try to access any nested property.

Anyway this is subject to improvement and discussion.

@leoasis leoasis requested review from rosskevin and jbaxleyiii Jan 25, 2018

@jbaxleyiii jbaxleyiii merged commit 12821cf into apollographql:master Jan 25, 2018

3 of 4 checks passed

bundlesize ./lib/react-apollo.browser.umd.js: 5.92KB > maxSize 5.9KB gzip
Details
CLA Author has signed the Meteor CLA.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.007%) to 96.026%
Details

@leoasis leoasis deleted the leoasis:query_component_ts_improvements branch Jan 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment