From 2a7a41d7e5d80a8095ac07ac3a74bdde92bb5610 Mon Sep 17 00:00:00 2001 From: Ewan Lyon Date: Sat, 2 Mar 2024 17:38:02 +1100 Subject: [PATCH] fix: add object arrays --- src/use-replicant.ts | 2 +- tests/use-replicant.spec.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/use-replicant.ts b/src/use-replicant.ts index b28b093..86050e3 100644 --- a/src/use-replicant.ts +++ b/src/use-replicant.ts @@ -3,7 +3,7 @@ import { klona as clone } from "klona/json"; type JsonValue = boolean | number | string | null; -type Json = JsonValue | JsonValue[] | { [key: string]: Json }; +type Json = JsonValue | JsonValue[] | { [key: string]: Json } | Json[]; export type UseReplicantOptions = { defaultValue?: T; diff --git a/tests/use-replicant.spec.tsx b/tests/use-replicant.spec.tsx index 6a28933..ef5ecbe 100644 --- a/tests/use-replicant.spec.tsx +++ b/tests/use-replicant.spec.tsx @@ -72,10 +72,16 @@ interface RunnerNameProps { prefix?: string; } +type RunnerNameReplicant = { + runner: { + name: string; + }; +}; + const RunnerName: React.FC = (props) => { const { prefix } = props; const repName = `${prefix ?? "default"}:currentRun`; - const [currentRun] = useReplicant(repName, { + const [currentRun] = useReplicant(repName, { defaultValue: { runner: { name: "foo" } }, }); if (!currentRun) {