From 420331c4b48fbe7465dcf21fd109c7efe50ccd54 Mon Sep 17 00:00:00 2001 From: Richard Jacquier Date: Thu, 26 Sep 2024 16:39:16 +1000 Subject: [PATCH 1/2] fix(web) type NonSuspenseCellQueryResult... Pass through `TData`, instead of `any` --- packages/web/src/components/cell/cellTypes.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 From f197350e7ffdd1a0a5197b39dd315a85b7f28517 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Thu, 3 Oct 2024 12:03:16 +0200 Subject: [PATCH 2/2] changeset --- .changesets/11639.md | 5 +++++ 1 file changed, 5 insertions(+) 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`).