diff --git a/packages/ui/src/providers/ServerFunctions/index.tsx b/packages/ui/src/providers/ServerFunctions/index.tsx index 24f9b6c3d6..758f30b051 100644 --- a/packages/ui/src/providers/ServerFunctions/index.tsx +++ b/packages/ui/src/providers/ServerFunctions/index.tsx @@ -48,7 +48,9 @@ type RenderDocument = (args: { redirectAfterDelete?: boolean redirectAfterDuplicate?: boolean signal?: AbortSignal -}) => Promise<{ data: Data; Document: React.ReactNode } | ErrorResult> +}) => Promise< + { data: Data; Document: React.ReactNode } | ({ data: never; Document: never } & ErrorResult) +> type CopyDataFromLocaleClient = ( args: { @@ -204,7 +206,7 @@ export const ServerFunctionsProvider: React.FC<{ const result = (await serverFunction({ name: 'render-document', args: { fallbackLocale: false, ...rest }, - })) as { data: Data; Document: React.ReactNode } | ErrorResult + })) as Awaited> // TODO: infer this type when `strictNullChecks` is enabled handleErrors(result as ErrorResult) diff --git a/packages/ui/src/utilities/buildTableState.ts b/packages/ui/src/utilities/buildTableState.ts index c9ccd7eedc..c33c66b973 100644 --- a/packages/ui/src/utilities/buildTableState.ts +++ b/packages/ui/src/utilities/buildTableState.ts @@ -26,19 +26,17 @@ type BuildTableStateSuccessResult = { Table: React.ReactNode } -type BuildTableStateErrorResult = +type BuildTableStateErrorResult = { + data?: any + renderedFilters?: never + state?: never + Table?: never +} & ( | { - data?: any - renderedFilters?: never - state?: never - Table?: never + message: string } - | ( - | { - message: string - } - | ErrorResult - ) + | ErrorResult +) export type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult