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.
useSubscription allows to omit
config.subscription
andconfig.variables
ifopts.skip
is literally true.I.e.
subscription
andvariables
are optional only when we explicitly pass true to skip option:useSubscription(config, { skip: true })
.But in reality we never do it like this
skip: true
. We always use some variable. For example like thisuseSubscription(config, { skip: !userId })
.But in this case with current typescript type if we use
skip: !userId
subscription and variables are required.This PR makes
config.subscription
andconfig.variables
optional whenever we provide skip option. The value of skip option can be known in runtime only.The problem code example:
With a fix I think code can be clearer:
@morrys I'm not sure what test to write for this, there is no runtime changes. Please let me know if it makes sense at all.
I made a change in our project and there was only 1 typescript error because in that place we didn't use generic param with useSubscription.
Thanks,
Aleksandr