-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(v5): type queryResult
in Cells
#8175
Conversation
Do we need to make the same change for Empty, Loading and Failure too? |
@Tobbe ah yeah great catch, just pushed those changes up |
@@ -104,14 +106,13 @@ export type CellSuccessData<TData = any> = Omit<Guaranteed<TData>, '__typename'> | |||
export type CellSuccessProps< | |||
TData = any, | |||
TVariables extends OperationVariables = any | |||
> = Partial< | |||
Omit< | |||
> = Partial<{ |
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.
Sorry I didn't catch this earlier, but I wonder if Partial<>
isn't in the wrong spot now. I could be wrong here, so please validate my claims. But I think what you're saying now is that queryResult
might or might not be present. And updating
might or might not be present.
Basically this:
type CellSuccessProps = {
queryResult?: { ... }
updating?: boolean
}
Whereas what we had before was everything "inside" queryResult
being optional.
So, maybe what we need is something like
type CellSuccessProps = {
queryResult: Partial<{ ... }>
updating: boolean
}
I removed the ?
after both queryResult
and updating
. I'm not sure if for example updating
can be undefined
, and if so, how React will treat <Success updating={undefined}>
. If it can be undefined
, and react then doesn't include it in the props for <Success>
, then we need to add the ?
.
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.
Yeah I thought about this briefly. We had Partial
wrapping the whole type before so pretty much everything except for the data comes back as being possible undefined:
Including updating
:
It makes sense to make queryResult
's contents Partial but not the prop itself, but making updating
not possibly undefined would be a change I haven't considered yet. Open to anything though I just haven't through it through, was just trying to fix the bug
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.
With the typing the way it is I have to pass queryResult
like this in the type test now; maybe it's not a big deal since it'll be passed by the Cell to Success, etc automatically: 6404619
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.
Open to anything though I just haven't through it through, was just trying to fix the bug
You're right. Let's focus on the actual bug! 🙂
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.
With the typing the way it is I have to pass
queryResult
like this in the type test now
I think that's correct. The "input" to a cell should/will have queryResult
.
* fix(v5): type queryResult * make type change for faliure and loading * Partial queryResult's contents * fix failing type test * continue fixing type tests * update test project fixture * remove glob dependency * fix type errors in smoke test * revert changes to type tests
* fix(v5): type queryResult * make type change for faliure and loading * Partial queryResult's contents * fix failing type test * continue fixing type tests * update test project fixture * remove glob dependency * fix type errors in smoke test * revert changes to type tests
Fixes #7024 (comment). @Tobbe works in VS Code with
yarn rwfw
going, but do you think it's this simple?