Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit f6375da

Browse files
os-justinclaude
andauthored
feat(types): export ComboboxOption from the root entry (#8177)
objectui#7691 made `@object-ui/types` the single AUTHORITY for `ComboboxOption` — `@object-ui/components` stopped declaring its own copy and now re-exports this one — but reached it only through the `@object-ui/types/form` subpath, because the root barrel was held by objectui#7683 at the time. Measured on `a4611b3e2`, the name read 0 hits on `packages/types/src/index.ts` while `SelectOption` (2), `RadioOption` (1) and `ComboboxSchema` (1) all read non-zero under the same word-boundary query, so the zero was a reading rather than a dark instrument, and `import type { ComboboxOption } from '@object-ui/types'` read TS2305. Add the name to the barrel's existing named re-export list from `./form.js`, next to `ComboboxSchema` the way `SelectSchema`/`SelectOption` and `RadioGroupSchema`/`RadioOption` already sit. Additive only: the list stays an explicit named list (never a wildcard, which would publish every other name in `form.ts` as a side effect), the declaration stays in `form.ts`, the three declared members are unchanged, and the `/form` subpath keeps working. The new pin asserts BOTH spellings, because having put the name on the barrel the most likely later "tidy" is to drop the subpath as redundant: the type level pins each declared member through each entry point plus their invariant equality (one declaration, not two forks), the source scan pins the explicit named list and the declaration's location, and the manifest pin keeps `exports["./form"]` pointing at the built subpath entry. The source scan is what runs under `pnpm test`, which has no build step ahead of it, so nothing here reads `dist/`. Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S Co-authored-by: Claude <noreply@anthropic.com>
1 parent 153d432 commit f6375da

3 files changed

Lines changed: 261 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'@object-ui/types': minor
3+
---
4+
5+
Export `ComboboxOption` from the `@object-ui/types` root entry (objectui#7697).
6+
7+
**Additive only.** `ComboboxOption` is added to the root barrel's existing named
8+
re-export list from `./form.js`, next to the sibling option types that were already
9+
there (`SelectOption`, `RadioOption`). Nothing is removed, retyped or narrowed: the
10+
declaration stays in `src/form.ts`, its three members (`value`, `label`, `disabled?`)
11+
are unchanged, and the `@object-ui/types/form` subpath spelling keeps working exactly
12+
as before. Both spellings now resolve to the same declaration.
13+
14+
**Why it was missing.** objectui#7691 made this package the single authority for the
15+
name — `@object-ui/components` stopped declaring its own copy and now re-exports this
16+
one — but reached it through the `/form` subpath, because the root barrel was held by
17+
objectui#7683 at the time. That choice was deliberate and was judged sound on its own
18+
merits (the subpath is a house pattern, alongside `@object-ui/types/zod` and
19+
`@object-ui/types/internal/retired-field-keys`); this release is the follow-up
20+
objectui#7691 could not take, not a correction of it.
21+
22+
**What changes for you.** `import type { ComboboxOption } from '@object-ui/types'` now
23+
compiles; on the previous release it read `TS2305` while its two siblings on the same
24+
list resolved. If you already import from `@object-ui/types/form`, or through
25+
`@object-ui/components`, nothing changes and no migration is needed — both remain
26+
supported and are pinned as such.
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
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+
* objectui#7697 — `ComboboxOption` is reachable from BOTH published entry
9+
* points of `@object-ui/types`: the root barrel and the `/form` subpath.
10+
*
11+
* ## The defect
12+
*
13+
* objectui#7691 made this package the single AUTHORITY for `ComboboxOption`:
14+
* `@object-ui/components` stopped declaring its own copy and now re-exports
15+
* this one (`packages/components/src/custom/combobox.tsx` imports and
16+
* re-exports it `from "@object-ui/types/form"`). But the authority was
17+
* reachable only through that subpath. Measured on `origin/main` `a4611b3e2`,
18+
* with the same word-boundary grep on `packages/types/src/index.ts`:
19+
*
20+
* | name | hits |
21+
* | -------------------------- | ---: |
22+
* | `ComboboxOption` | 0 |
23+
* | `SelectOption` (control) | 2 |
24+
* | `RadioOption` (control) | 1 |
25+
* | `ComboboxSchema` (control) | 1 |
26+
*
27+
* The instrument was lit — the three controls read non-zero under the same
28+
* query — so the zero was a reading, not a dark instrument. The consequence a
29+
* consumer saw was `TS2305` on `import type { ComboboxOption } from
30+
* '@object-ui/types'` while the two sibling option types on the same list,
31+
* `SelectOption` and `RadioOption`, resolved.
32+
*
33+
* ⛔ This is NOT a defect in objectui#7691. The subpath was chosen there
34+
* deliberately (the root barrel was held by objectui#7683 at the time, and a
35+
* barrel line would have been both a fence breach and a second
36+
* published-surface addition), and that review judged it sound on its own
37+
* merits — the subpath is a house pattern, alongside `@object-ui/types/zod`
38+
* and `@object-ui/types/internal/retired-field-keys`. This card is the
39+
* follow-up objectui#7691 could not take.
40+
*
41+
* ## Why BOTH spellings are pinned, and not just the new one
42+
*
43+
* The fix is ADDITIVE: one name added to the root barrel's existing named
44+
* re-export list. Nothing is removed, retyped or narrowed, and the subpath
45+
* keeps working. That is exactly the property a later "tidy" is most likely to
46+
* undo without noticing — having put the name on the barrel, dropping the
47+
* `./form` subpath or the components-side import looks like cleanup. Pinning
48+
* only the root spelling would have let that through green. So both are
49+
* asserted, at the type level AND at the manifest level, and neither is
50+
* allowed to stand in for the other.
51+
*
52+
* ## Why there is a SOURCE scan next to the type-level pins
53+
*
54+
* The type-level pins below are erased by the compiler, so they say nothing
55+
* during `pnpm test` — their enforcement is `tsc -p tsconfig.test.json`, the
56+
* third leg of this package's `type-check` script, which CI runs as its own
57+
* job. The source scan is the half that runs under `vitest`, and it is
58+
* deliberately NOT a `dist/` read: this repo's per-PR `test` job runs
59+
* `pnpm test` with no build step ahead of it (turbo's `test` task depends on
60+
* `^build`, the DEPENDENCY closure, never the package's own build), so a test
61+
* that needed a fresh `dist/` would be vacuously absent-or-red on a cold
62+
* cache. `package-exports-manifest.test.ts` records that same constraint for
63+
* the same package; this file follows it rather than re-litigating it.
64+
*
65+
* The scan also pins the two shapes the card ruled out by name:
66+
* ⛔ the list must stay an EXPLICIT named list, never `export * from
67+
* './form.js'` (a wildcard would satisfy "the name is reachable" while
68+
* deleting the deliberate list — and would publish every other name in
69+
* `form.ts` as a side effect), and ⛔ the declaration must stay in `form.ts`,
70+
* never move to `index.ts`.
71+
*/
72+
import { readFileSync } from 'node:fs';
73+
import { createRequire } from 'node:module';
74+
import { describe, it, expect } from 'vitest';
75+
76+
import type { ComboboxOption as FromRootBarrel } from '../index';
77+
import type { ComboboxOption as FromFormSubpath } from '../form';
78+
// The two controls: sibling option types that were ALREADY on the root
79+
// barrel's `./form.js` list before this change. If either of these fails to
80+
// resolve, every reading in this file is dark.
81+
import type { SelectOption as SelectFromRootBarrel } from '../index';
82+
import type { RadioOption as RadioFromRootBarrel } from '../index';
83+
84+
const require = createRequire(import.meta.url);
85+
86+
const readSource = (relative: string): string =>
87+
readFileSync(require.resolve(relative), 'utf8');
88+
89+
const INDEX_SRC = readSource('../index.ts');
90+
const FORM_SRC = readSource('../form.ts');
91+
92+
const pkg = JSON.parse(readSource('../../package.json')) as {
93+
exports?: Record<string, Record<string, string> | string>;
94+
};
95+
96+
/**
97+
* Invariant type equality — the house spelling (`chart-series-keys-7546`,
98+
* `chat-message-avatar-keys-7295`, and others). Assignability alone would call
99+
* a widened or `any`-resolved type a match; this does not.
100+
*/
101+
type Eq<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
102+
103+
/**
104+
* The bodies of every `export type { … } from './form.js';` clause in the root
105+
* barrel. There is exactly one, and the assertion below says so.
106+
*
107+
* The brace class is load-bearing, not tidiness. A lazy `[\s\S]*?` body reads
108+
* TWO matches here: the second one opens at some later `export type {` block
109+
* and closes on `index.ts`'s `import type { FormComponentSchema } from
110+
* './form.js';` — the only other line in the file ending in that exact
111+
* sequence — swallowing every export clause in between. Measured: it returned
112+
* 2, and the count assertion is what caught it.
113+
*/
114+
const formReExportBodies = (): string[] =>
115+
[...INDEX_SRC.matchAll(/export type \{([^{}]*?)\} from '\.\/form\.js';/gu)].map((m) => m[1] ?? '');
116+
117+
/** Every name on the root barrel's `./form.js` named re-export list. */
118+
const formReExportNames = (): string[] => {
119+
const bodies = formReExportBodies();
120+
// One clause, or the extraction below is reading a shape this file was not
121+
// written against and every membership answer under it is unreliable.
122+
expect(bodies).toHaveLength(1);
123+
return (bodies[0] ?? '')
124+
.split('\n')
125+
.map((line) => line.trim())
126+
// Drop the prose. The list carries `//` commentary that spells sibling
127+
// names (`SelectOption`, `RadioOption`), so a substring read of the raw
128+
// block would count comments as exports and the controls would read high
129+
// for the wrong reason.
130+
.filter((line) => line.length > 0 && !line.startsWith('//'))
131+
.map((line) => /^([A-Za-z_$][\w$]*)\s*,?$/u.exec(line)?.[1] ?? '')
132+
.filter((name) => name.length > 0);
133+
};
134+
135+
/* ── (a) the type level: both spellings resolve, to ONE declaration ───────── */
136+
137+
describe('objectui#7697 — `ComboboxOption` resolves from BOTH entry points', () => {
138+
it('resolves from the ROOT barrel, with its three declared members', () => {
139+
// RED on the untouched base: `../index` has no exported member
140+
// `ComboboxOption`, so the import above fails to resolve under
141+
// `tsc -p tsconfig.test.json` (TS2305) and each alias below is an error.
142+
//
143+
// Members are pinned one at a time rather than as a whole-shape equality:
144+
// a later key ADDED to the declaration is a decision for its own card, not
145+
// a reason for this one to red, but a member RETYPED here would be exactly
146+
// the "nothing retyped or narrowed" claim breaking.
147+
const value: Eq<FromRootBarrel['value'], string> = true;
148+
const label: Eq<FromRootBarrel['label'], string> = true;
149+
const disabled: Eq<FromRootBarrel['disabled'], boolean | undefined> = true;
150+
expect([value, label, disabled]).toEqual([true, true, true]);
151+
});
152+
153+
it('STILL resolves from the `/form` subpath — the fix removes nothing', () => {
154+
const value: Eq<FromFormSubpath['value'], string> = true;
155+
const label: Eq<FromFormSubpath['label'], string> = true;
156+
const disabled: Eq<FromFormSubpath['disabled'], boolean | undefined> = true;
157+
expect([value, label, disabled]).toEqual([true, true, true]);
158+
});
159+
160+
it('the two spellings are the SAME declaration, not two forks of one name', () => {
161+
// The point of objectui#7691 was one authority. A root-barrel line that
162+
// published a *different* `ComboboxOption` would satisfy both assertions
163+
// above and still reintroduce the two-meanings defect
164+
// `scripts/__tests__/one-authority-per-exported-name-6273.test.ts` guards.
165+
const same: Eq<FromRootBarrel, FromFormSubpath> = true;
166+
expect(same).toBe(true);
167+
});
168+
169+
it('CONTROL — the two sibling option types already on the list still resolve', () => {
170+
const select: Eq<SelectFromRootBarrel['value'], string | number | boolean> = true;
171+
const radio: Eq<RadioFromRootBarrel['value'], string | number> = true;
172+
expect([select, radio]).toEqual([true, true]);
173+
});
174+
});
175+
176+
/* ── (b) the source: an explicit named list, the declaration left in place ── */
177+
178+
describe('objectui#7697 — the root barrel lists the name, explicitly', () => {
179+
it('`ComboboxOption` is on the `./form.js` named re-export list', () => {
180+
// RED on the untouched base: the list closed without this name.
181+
expect(formReExportNames()).toContain('ComboboxOption');
182+
});
183+
184+
it('CONTROL — the siblings and the schema are on the same list', () => {
185+
// If these three fail, the extraction is dark and the reading above says
186+
// nothing. They are the same three controls the card measured.
187+
const names = formReExportNames();
188+
expect(names).toEqual(expect.arrayContaining(['SelectOption', 'RadioOption', 'ComboboxSchema']));
189+
});
190+
191+
it('the list is still an EXPLICIT named list — no wildcard from `./form.js`', () => {
192+
// ⛔ Ruled out by the card. A wildcard would make the assertion above
193+
// vacuous and would publish every other name in `form.ts` as a side
194+
// effect — a far wider surface change than the one this card authorises.
195+
expect(INDEX_SRC).not.toMatch(/export (?:type )?\* (?:as \w+ )?from '\.\/form\.js';/u);
196+
});
197+
198+
it('the declaration did NOT move — `form.ts` still owns it', () => {
199+
// ⛔ Also ruled out by the card: the fix is a barrel line, not a
200+
// relocation. `index.ts` re-exports; it never declares.
201+
expect(FORM_SRC).toMatch(/^export interface ComboboxOption\b/mu);
202+
expect(INDEX_SRC).not.toMatch(/\b(?:interface|type)\s+ComboboxOption\b/u);
203+
});
204+
});
205+
206+
/* ── (c) the manifest: the subpath cannot be silently dropped ─────────────── */
207+
208+
describe('objectui#7697 — the `/form` subpath stays a published entry point', () => {
209+
it('`exports["./form"]` still points at the built `form` entry', () => {
210+
// The type-level pin above proves `../form` COMPILES; only this proves the
211+
// spelling `@object-ui/types/form` is still resolvable by a consumer.
212+
// `packages/components/src/custom/combobox.tsx` is the live one.
213+
expect(pkg.exports?.['./form']).toEqual({
214+
types: './dist/form.d.ts',
215+
import: './dist/form.js',
216+
});
217+
});
218+
219+
it('CONTROL — the root entry point is declared too', () => {
220+
// Its exact shape is pinned by `package-exports-manifest.test.ts`
221+
// (objectui#4896); restated here only as the control that keeps the
222+
// reading above from being a dark instrument.
223+
expect(pkg.exports?.['.']).toBeDefined();
224+
});
225+
});

‎packages/types/src/index.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ export type {
174174
FormFieldTab,
175175
FormFieldPane,
176176
ComboboxSchema,
177+
// The element type of `ComboboxSchema.options`, listed next to its schema the
178+
// way `SelectSchema`/`SelectOption` and `RadioGroupSchema`/`RadioOption`
179+
// already are (objectui#7697). objectui#7691 made this package the single
180+
// AUTHORITY for the name — `@object-ui/components` re-exports this
181+
// declaration instead of forking its own — but left it reachable only
182+
// through the `@object-ui/types/form` subpath, so the root spelling read
183+
// TS2305. This line is purely ADDITIVE: the subpath keeps working, and
184+
// `combobox-option-root-barrel-7697.test.ts` pins BOTH spellings so a later
185+
// tidy cannot silently drop either one.
186+
ComboboxOption,
177187
CommandSchema,
178188
InputOTPSchema,
179189
ToggleSchema,

0 commit comments

Comments
 (0)