From f480adcf943cb5e96be427f738f8bf20c6d0d8c3 Mon Sep 17 00:00:00 2001 From: Railly Hugo Date: Wed, 7 Oct 2026 14:05:35 -0300 Subject: [PATCH 1/2] fix(core): infer s.any() fields as any InferSpecField mapped SchemaType<"any"> to unknown, so catalog.validate() data with a visible: s.any() field was not assignable to Spec and needed an as unknown as Spec cast. Co-Authored-By: Trevin Chow --- packages/core/src/schema.test.ts | 16 ++++++++++++++++ packages/core/src/schema.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/core/src/schema.test.ts b/packages/core/src/schema.test.ts index 9629de1a..2f567892 100644 --- a/packages/core/src/schema.test.ts +++ b/packages/core/src/schema.test.ts @@ -1,6 +1,7 @@ import { describe, it, expect } from "vitest"; import { z } from "zod"; import { defineSchema, defineCatalog } from "./schema"; +import type { Spec } from "./types"; // ============================================================================= // Shared test schema (mirrors the React schema shape) @@ -565,6 +566,21 @@ describe("catalog.validate", () => { actions: {}, }); + it("returns data assignable to Spec", () => { + const result = catalog.validate({ + root: "card-1", + elements: { + "card-1": { type: "Card", props: { title: "Hello" }, children: [] }, + }, + }); + expect(result.success).toBe(true); + if (result.success && result.data) { + // s.any() fields such as `visible` must not infer as unknown. + const spec: Spec = result.data; + expect(spec.root).toBe("card-1"); + } + }); + it("validates a valid spec", () => { const spec = { root: "card-1", diff --git a/packages/core/src/schema.ts b/packages/core/src/schema.ts index e5aa0bf4..a5e954dd 100644 --- a/packages/core/src/schema.ts +++ b/packages/core/src/schema.ts @@ -355,7 +355,7 @@ type InferSpecField = : T extends SchemaType<"propsOf", infer Path> ? InferPropsOfType : T extends SchemaType<"any"> - ? unknown + ? any : unknown; type InferRefType = Path extends "catalog.components" From 3ea6b5398442a292dc7f6f3f274548aa3c671762 Mon Sep 17 00:00:00 2001 From: Railly Hugo Date: Sat, 10 Oct 2026 02:28:19 -0300 Subject: [PATCH 2/2] ci(core): type-check the schema inference test core had no check-types script, so turbo skipped it and reverting the s.any() inference fix still passed CI. A focused tsconfig checks src/schema.test.ts; the full core project still fails tsc on main (TS6059, test-only errors). --- packages/core/package.json | 1 + packages/core/tsconfig.check.json | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 packages/core/tsconfig.check.json diff --git a/packages/core/package.json b/packages/core/package.json index 93f6cb51..c542a3bb 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -47,6 +47,7 @@ "scripts": { "build": "tsup", "dev": "tsup --watch", + "check-types": "tsc -p tsconfig.check.json", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/core/tsconfig.check.json b/packages/core/tsconfig.check.json new file mode 100644 index 00000000..d7993566 --- /dev/null +++ b/packages/core/tsconfig.check.json @@ -0,0 +1,9 @@ +{ + // Type-checks the tests that assert inferred types. The full core + // project is not type-checked in CI yet. + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true + }, + "include": ["src/schema.test.ts"] +}