From 3ef28ca3a183a8bd5c24d8c587eddbf02400c75d Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Thu, 28 May 2026 22:53:18 +0800 Subject: [PATCH] test(runtime-tests): pin JSX children typing under the automatic runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The WithChildren shim is only exercised under jsx:"react-jsx", which lives solely in integration/pty/fixtures/tsconfig.json. Nothing in `ready` ran tsc against that config (vp check uses jsx:"preserve" and excludes the fixtures; pty-test only transpiles them), so a regression in the shim — children silently rejected, or declared props silently widened away — would pass verification unnoticed. Add a type-only regression fixture (not a runnable PTY program; not a *.test.tsx, so vitest never collects it) that pins both directions of the contract: children are accepted on Box/Text/Static/Transform, and declared props stay validated via @ts-expect-error (invalid value, wrong type, unknown prop, and missing required props on Transform/Static). Wire `tsc -p integration/pty/fixtures/tsconfig.json --noEmit` into `ready` via a typecheck:fixtures script, run after build (so @vue-tui/runtime resolves against fresh dist types) and before pty-test, so the react-jsx path is actually enforced rather than only manually checkable. --- package.json | 2 +- .../pty/fixtures/jsx-children-types.tsx | 42 +++++++++++++++++++ packages/runtime-tests/package.json | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 packages/runtime-tests/integration/pty/fixtures/jsx-children-types.tsx diff --git a/package.json b/package.json index 1bdbf4f..aedc4de 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "Vue 3 terminal UI framework. Build AI agent interfaces and TUI apps with Yoga flexbox.", "type": "module", "scripts": { - "ready": "vp check && vp run -r test && vp run -r build && cd packages/runtime-tests && pnpm pty-test", + "ready": "vp check && vp run -r test && vp run -r build && cd packages/runtime-tests && pnpm typecheck:fixtures && pnpm pty-test", "dev": "vp run website#dev", "prepare": "vp config" }, diff --git a/packages/runtime-tests/integration/pty/fixtures/jsx-children-types.tsx b/packages/runtime-tests/integration/pty/fixtures/jsx-children-types.tsx new file mode 100644 index 0000000..c576f46 --- /dev/null +++ b/packages/runtime-tests/integration/pty/fixtures/jsx-children-types.tsx @@ -0,0 +1,42 @@ +/** + * Type-only regression fixture — NOT a runnable PTY program (nothing spawns it, + * and it is not a `*.test.tsx` so vitest never collects it). It exists purely so + * `tsc -p integration/pty/fixtures/tsconfig.json` type-checks it. + * + * It pins the contract the `WithChildren` shim establishes under the automatic + * JSX runtime (`jsx: "react-jsx"`, this dir's tsconfig — the mode the main + * runtime-tests tsconfig does NOT use): components accept JSX children while + * their declared props stay fully validated. If the shim regresses in either + * direction, this file fails to compile: + * - children rejected -> the `accepted` cases error + * - prop validation lost -> the `@ts-expect-error` directives become unused + */ +import { Box, Static, Text, Transform } from "@vue-tui/runtime"; + +// Children are accepted (the shim's whole purpose under the automatic runtime). +export const accepted = [ + plain text child, + + nested child + , + + static child + , + line}> + transformed child + , +]; + +// Declared props stay validated — children must not widen the prop bag. +export const rejected = [ + // @ts-expect-error `display` accepts "flex" | "none", not a number + x, + // @ts-expect-error `bold` accepts a boolean, not a string + x, + // @ts-expect-error `bogusProp` is not a declared Box prop + x, + // @ts-expect-error `transform` is required + x, + // @ts-expect-error `items` is required + x, +]; diff --git a/packages/runtime-tests/package.json b/packages/runtime-tests/package.json index e24db9f..a883435 100644 --- a/packages/runtime-tests/package.json +++ b/packages/runtime-tests/package.json @@ -6,6 +6,7 @@ "scripts": { "test": "vp test", "pty-test": "vp test run --config vitest.pty.config.ts --passWithNoTests", + "typecheck:fixtures": "tsc -p integration/pty/fixtures/tsconfig.json --noEmit", "check": "vp check" }, "devDependencies": {