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 Query and graphql types. Strict type check with Typescript. #1617

Merged
merged 17 commits into from Feb 1, 2018

Conversation

Projects
None yet
2 participants
@leoasis
Copy link
Collaborator

leoasis commented Feb 1, 2018

This PR switches the project to use strict typechecking with Typescript, which unconvers a lot of new errors that aim to help us catch more bugs, particularly around null checks and wrong function calls.

Also improved the types for the Query component a bit, so they are more generic and don't lose type information in functions such as updateQuery or fetchMore. Since these are ultimately functions that live in apollo-client, those should be improved there as well (that will come eventually in a PR to that repo), but I improved the types for this particular case since it's a new component and it would decrease the breaking changes. However, I did improve the types a bit in the graphql HoC, as far as I could (didn't override the types that were imported from apollo-client in this case).

One caveat this new strict mode has (which is a fair one IMO) is that decorators cause errors when used in this setup. They raise type errors in all cases where you define a lifecycle hook (see Microsoft/TypeScript#17989). Anyway I think we shouldn't be using decorators with Typescript, both because they are still not a standard, and second because they don't have the exactly same semantics as we intend to use them here (the idea is that we don't change the external API of a class when a decorator is applied, but this is not the case).

Sorry for the big PR, but this implied touching all the files since they all had some sort of error in strict mode.

Also let's discuss if we want to add this as part of the 2.1 beta or if this should be part of a new release 2.2 or something.

Closes #1589

@rosskevin rosskevin referenced this pull request Feb 1, 2018

Closed

`require` in .mjs files #1589

@rosskevin
Copy link
Collaborator

rosskevin left a comment

I agree we should stop/drop decorators until there is something stable. There are a few issues on CI but otherwise I definitely approve of this great work.

@leoasis leoasis force-pushed the leoasis:strict_type_check branch from 4720d02 to 2cbd088 Feb 1, 2018

@leoasis leoasis merged commit 4b05041 into apollographql:master Feb 1, 2018

4 checks passed

CLA Author has signed the Meteor CLA.
Details
bundlesize ./lib/react-apollo.browser.umd.js: 6.09KB < maxSize 6.5KB (gzip)(117B larger than master, careful!)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.7%) to 95.387%
Details

@leoasis leoasis deleted the leoasis:strict_type_check branch Feb 1, 2018

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