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

Improve Query and graphql types. Strict type check with Typescript.#1617

Merged
leoasis merged 17 commits intoapollographql:masterfrom
leoasis:strict_type_check
Feb 1, 2018
Merged

Improve Query and graphql types. Strict type check with Typescript.#1617
leoasis merged 17 commits intoapollographql:masterfrom
leoasis:strict_type_check

Conversation

@leoasis
Copy link
Copy Markdown
Contributor

@leoasis 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 mentioned this pull request Feb 1, 2018
Copy link
Copy Markdown
Contributor

@rosskevin rosskevin left a 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 leoasis merged commit 4b05041 into apollographql:master Feb 1, 2018
@leoasis leoasis deleted the strict_type_check branch February 1, 2018 15:45
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 this pull request may close these issues.

2 participants