Undefined typre for useSyncedShape

This commit is contained in:
Matt Aitken
2024-09-02 16:06:49 +01:00
parent 1aad21a892
commit ddc1db1849
3 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ export type Trace = ReturnType<typeof createTraceTreeFromEvents>;
export type TraceEvent = Trace["events"][number];
export function useSyncTrace({ origin, traceId }: Params) {
const { isUpToDate, data } = useShape({
const { isUpToDate, data, error, isError } = useShape({
url: `${origin}/sync/traces/${traceId}`,
});
+1 -2
View File
@@ -1,7 +1,6 @@
import { useShape } from "@electric-sql/react";
import { Prettify } from "@trigger.dev/core";
import { TaskRun } from "@trigger.dev/database";
import { SyncedShapeData, useSyncedShape } from "./useSyncedShape";
import { Prettify } from "@trigger.dev/core";
type Params = {
origin: string;
+4 -2
View File
@@ -4,7 +4,7 @@ export type ShapeInput = Parameters<typeof useShape>[0];
export type ShapeOutput<S> = {
isError: boolean;
isUpToDate: boolean;
data: S[];
data: S[] | undefined;
};
export type SyncedShapeData<T> = {
@@ -27,7 +27,9 @@ export function useSyncedShape<S>(props: ShapeInput): ShapeOutput<SyncedShapeDat
return {
isError: output.isError,
isUpToDate: output.isUpToDate,
data: transformInput(output.data as InputObject) as SyncedShapeData<S>[],
data: output.data
? (transformInput(output.data as InputObject) as SyncedShapeData<S>[])
: undefined,
};
}