This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 787
Improve Query and graphql types. Strict type check with Typescript. #1617
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
rosskevin
approved these changes
Feb 1, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
force-pushed
the
strict_type_check
branch
from
February 1, 2018 15:38
4720d02
to
2cbd088
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 asupdateQuery
orfetchMore
. Since these are ultimately functions that live inapollo-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 thegraphql
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