test(runtime-tests): pin JSX children typing under the automatic runtime
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.
This commit is contained in:
@@ -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 = [
|
||||
<Text color="green">plain text child</Text>,
|
||||
<Box flexDirection="row">
|
||||
<Text>nested child</Text>
|
||||
</Box>,
|
||||
<Static items={[1, 2, 3]}>
|
||||
<Text>static child</Text>
|
||||
</Static>,
|
||||
<Transform transform={(line) => line}>
|
||||
<Text>transformed child</Text>
|
||||
</Transform>,
|
||||
];
|
||||
|
||||
// Declared props stay validated — children must not widen the prop bag.
|
||||
export const rejected = [
|
||||
// @ts-expect-error `display` accepts "flex" | "none", not a number
|
||||
<Box display={123}>x</Box>,
|
||||
// @ts-expect-error `bold` accepts a boolean, not a string
|
||||
<Text bold="yes">x</Text>,
|
||||
// @ts-expect-error `bogusProp` is not a declared Box prop
|
||||
<Box bogusProp="x">x</Box>,
|
||||
// @ts-expect-error `transform` is required
|
||||
<Transform>x</Transform>,
|
||||
// @ts-expect-error `items` is required
|
||||
<Static>x</Static>,
|
||||
];
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user