From bf55845d15987f33c0157f152672873c98667720 Mon Sep 17 00:00:00 2001 From: Richard J <106497642+richard-stafflink@users.noreply.github.com> Date: Thu, 3 Oct 2024 20:30:01 +1000 Subject: [PATCH] fix(web) type NonSuspenseCellQueryResult... (#11639) Co-authored-by: Tobbe Lundberg --- .changesets/11639.md | 5 +++++ packages/web/src/components/cell/cellTypes.ts | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changesets/11639.md diff --git a/.changesets/11639.md b/.changesets/11639.md new file mode 100644 index 000000000000..8a27c35c7e3b --- /dev/null +++ b/.changesets/11639.md @@ -0,0 +1,5 @@ +- fix(web) type NonSuspenseCallQueryResult... (#11639) by @richard-stafflink + +The result you get back as `queryResult` is now properly typed. Typically the +type will be something like `FindPostById`, i.e. the first type that is passed +to `CellSuccessProps` (instead of just being `any`). diff --git a/packages/web/src/components/cell/cellTypes.ts b/packages/web/src/components/cell/cellTypes.ts index bc6d9a8318ab..90f23fd7e018 100644 --- a/packages/web/src/components/cell/cellTypes.ts +++ b/packages/web/src/components/cell/cellTypes.ts @@ -52,11 +52,15 @@ export type CellProps< > export type CellLoadingProps = { - queryResult?: NonSuspenseCellQueryResult | SuspenseCellQueryResult + queryResult?: + | NonSuspenseCellQueryResult + | SuspenseCellQueryResult } export type CellFailureProps = { - queryResult?: NonSuspenseCellQueryResult | SuspenseCellQueryResult + queryResult?: + | NonSuspenseCellQueryResult + | SuspenseCellQueryResult error?: QueryOperationResult['error'] | Error // for tests and storybook /** @@ -106,7 +110,9 @@ export type CellSuccessProps< TData = any, TVariables extends OperationVariables = any, > = { - queryResult?: NonSuspenseCellQueryResult | SuspenseCellQueryResult + queryResult?: + | NonSuspenseCellQueryResult + | SuspenseCellQueryResult updating?: boolean } & A.Compute> // pre-computing makes the types more readable on hover @@ -199,8 +205,9 @@ export type SuspendingSuccessProps = React.PropsWithChildren< export type NonSuspenseCellQueryResult< TVariables extends OperationVariables = any, + TData = any, > = Partial< - Omit, 'loading' | 'error' | 'data'> + Omit, 'loading' | 'error' | 'data'> > // We call this queryResult in createCell, sadly a very overloaded term