|
| 1 | +/** |
| 2 | + * ObjectUI |
| 3 | + * Copyright (c) 2024-present ObjectStack Inc. |
| 4 | + * |
| 5 | + * This source code is licensed under the MIT license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * objectui#12464: `@objectstack/spec` 18 retired the page kind `jsx` |
| 11 | + * (objectstack-ai/objectstack#23638), naming `html` as its replacement, so the |
| 12 | + * SDUI page node no longer declares it. |
| 13 | + * |
| 14 | + * The assertions are TYPE-level: they are judged by this package's |
| 15 | + * `type-check` (its `tsc -p tsconfig.test.json` leg), never by vitest, which |
| 16 | + * strips types. A `@ts-expect-error` that stops being needed is TS2578, so the |
| 17 | + * directive below fails in both directions. |
| 18 | + * |
| 19 | + * `Equal` (not `Extends`) on the whole union: re-adding `'jsx'` widens it, and |
| 20 | + * only an exact comparison fails on a widening. |
| 21 | + */ |
| 22 | +import { describe, expect, it } from 'vitest'; |
| 23 | +import type { PageNodeSchema } from '../layout'; |
| 24 | + |
| 25 | +type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false; |
| 26 | +type Assert<T extends true> = T; |
| 27 | + |
| 28 | +type _KindIsTheSpecVocabulary = Assert< |
| 29 | + Equal<NonNullable<PageNodeSchema['kind']>, 'full' | 'slotted' | 'html' | 'react'> |
| 30 | +>; |
| 31 | + |
| 32 | +describe('PageNodeSchema.kind no longer declares the retired page kind jsx (objectui#12464)', () => { |
| 33 | + it('refuses kind jsx and accepts its replacement html', () => { |
| 34 | + const html: PageNodeSchema = { type: 'page', kind: 'html', source: '<Page />' }; |
| 35 | + // @ts-expect-error `jsx` was retired from the page kind in @objectstack/spec 18; author `html` |
| 36 | + const jsx: PageNodeSchema = { type: 'page', kind: 'jsx', source: '<Page />' }; |
| 37 | + expect([html.kind, jsx.kind]).toEqual(['html', 'jsx']); |
| 38 | + }); |
| 39 | +}); |
0 commit comments