Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .changeset/11573-any-component-emit-headroom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
'@object-ui/types': patch
---

fix(types): `AnyComponentSchema`'s declaration prints every category union by name, so `@object-ui/types` no longer sits at the edge of TypeScript's serialization ceiling (objectui#11573)

`tsc` prints an inferred type in full wherever a declaration uses it, and past
its serialization ceiling it refuses with TS7056 ("The inferred type of this
node exceeds the maximum length the compiler will serialize"). `@object-ui/types`
then emits no declarations, and every consumer of `@object-ui/types/zod` fails
with TS7016. `AnyComponentSchema` listed every category union inline, so its
declaration printed the sum of all of them: measured with TypeScript's own
counter, it read under one percent short of the ceiling against
`@objectstack/spec` built from objectstack `main`, and the Spec Main Shape Gate
had already gone red on it once.

Each of the sixteen category unions `AnyComponentSchema` lists now has a named
type in its own module — an interface that extends the union's inferred type
and adds no member (`LayoutZodType`, `PublicBlockComponentZodType` and their
siblings) — and `AnyComponentSchema`'s declaration prints a reference to each
instead of its body.

What changes for a consumer is the printed `.d.ts` TEXT of existing exports,
and nothing else: `AnyComponentSchema` and the sixteen unions are the same
values, and every type read through `z.input` / `z.output` is unchanged. The
new names are exported from their own modules, which is what lets the
declaration reference them; they are not added to the `@object-ui/types/zod`
entry, so nothing new is importable.

`packages/types/src/__tests__/any-component-emit-headroom-11573.test.ts` reads
the declaration's size with the compiler's own counter, fails when it crosses a
tenth of the ceiling below it, and lists every member as named or inline.
375 changes: 375 additions & 0 deletions packages/types/src/__tests__/any-component-emit-headroom-11573.test.ts

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion packages/types/src/zod/ai.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,21 @@ export const NLQuerySchema = BaseSchema.extend({
* Union of the AI component arms — the category member `AnyComponentSchema`
* lists (objectui#10859).
*/
export const AIComponentSchema = z.discriminatedUnion('type', [
const AIComponentSchemaInferred = z.discriminatedUnion('type', [
AIFormAssistSchema,
AIRecommendationsSchema,
NLQuerySchema,
]);

/**
* The TYPE of {@link AIComponentSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface AIComponentZodType extends AIComponentSchemaInferredType {
options: AIComponentSchemaInferredType['options'];
}
type AIComponentSchemaInferredType = typeof AIComponentSchemaInferred;

/** The union above, typed by its named {@link AIComponentZodType}. */
export const AIComponentSchema: AIComponentZodType = AIComponentSchemaInferred;
15 changes: 14 additions & 1 deletion packages/types/src/zod/complex.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ export const DashboardConfigSchema = z.object({
/**
* Complex Schema Union - All complex component schemas
*/
export const ComplexSchema = z.discriminatedUnion('type', [
const ComplexSchemaInferred = z.discriminatedUnion('type', [
RetiredKanbanNodeSchema,
CalendarViewSchema,
FilterBuilderSchema,
Expand All @@ -1653,3 +1653,16 @@ export const ComplexSchema = z.discriminatedUnion('type', [
ChatbotFloatingSchema,
DashboardComponentSchema,
]);

/**
* The TYPE of {@link ComplexSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface ComplexZodType extends ComplexSchemaInferredType {
options: ComplexSchemaInferredType['options'];
}
type ComplexSchemaInferredType = typeof ComplexSchemaInferred;

/** The union above, typed by its named {@link ComplexZodType}. */
export const ComplexSchema: ComplexZodType = ComplexSchemaInferred;
15 changes: 14 additions & 1 deletion packages/types/src/zod/crud.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export const CRUDDialogSchema = BaseSchema.extend({
* does. ⛔ Not an accept-set change: all three arms already declared `type` as a
* distinct `z.literal` (`action` · `detail` · `crud-dialog`).
*/
export const CRUDComponentSchema = z.discriminatedUnion('type', [
const CRUDComponentSchemaInferred = z.discriminatedUnion('type', [
// `ActionSchema`'s `z.ZodType<ActionDeclaration, ActionDeclaration>` annotation
// is a maintainer ruling (objectui#7760, decision batch #69) and ⛔ does not
// move here. That type declares `_zod.propValues` as `PropValues | undefined`,
Expand All @@ -297,6 +297,19 @@ export const CRUDComponentSchema = z.discriminatedUnion('type', [
CRUDDialogSchema,
]);

/**
* The TYPE of {@link CRUDComponentSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface CRUDComponentZodType extends CRUDComponentSchemaInferredType {
options: CRUDComponentSchemaInferredType['options'];
}
type CRUDComponentSchemaInferredType = typeof CRUDComponentSchemaInferred;

/** The union above, typed by its named {@link CRUDComponentZodType}. */
export const CRUDComponentSchema: CRUDComponentZodType = CRUDComponentSchemaInferred;

/**
* Export type inference helpers
*/
Expand Down
15 changes: 14 additions & 1 deletion packages/types/src/zod/data-display.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ export const BarChartSchema = BaseSchema.extend({
children: retirementTombstone(BAR_CHART_NEITHER_CHANNEL),
});

export const DataDisplaySchema = z.discriminatedUnion('type', [
const DataDisplaySchemaInferred = z.discriminatedUnion('type', [
AlertSchema,
StatisticSchema,
BadgeSchema,
Expand All @@ -1690,3 +1690,16 @@ export const DataDisplaySchema = z.discriminatedUnion('type', [
HtmlSchema,
BarChartSchema,
]);

/**
* The TYPE of {@link DataDisplaySchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface DataDisplayZodType extends DataDisplaySchemaInferredType {
options: DataDisplaySchemaInferredType['options'];
}
type DataDisplaySchemaInferredType = typeof DataDisplaySchemaInferred;

/** The union above, typed by its named {@link DataDisplayZodType}. */
export const DataDisplaySchema: DataDisplayZodType = DataDisplaySchemaInferred;
15 changes: 14 additions & 1 deletion packages/types/src/zod/designer.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,24 @@ export const FieldDesignerSchema = BaseSchema.extend({
* because `DesignerComponentSchema` is the canvas component's mirror above
* (the `ReportUnionSchema` precedent in `reports.zod.ts`).
*/
export const DesignerUnionSchema = z.discriminatedUnion('type', [
const DesignerUnionSchemaInferred = z.discriminatedUnion('type', [
PageDesignerSchema,
DataModelDesignerSchema,
ProcessDesignerSchema,
ReportDesignerSchema,
ObjectManagerSchema,
FieldDesignerSchema,
]);

/**
* The TYPE of {@link DesignerUnionSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface DesignerUnionZodType extends DesignerUnionSchemaInferredType {
options: DesignerUnionSchemaInferredType['options'];
}
type DesignerUnionSchemaInferredType = typeof DesignerUnionSchemaInferred;

/** The union above, typed by its named {@link DesignerUnionZodType}. */
export const DesignerUnionSchema: DesignerUnionZodType = DesignerUnionSchemaInferred;
15 changes: 14 additions & 1 deletion packages/types/src/zod/disclosure.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,21 @@ export const ToggleGroupSchema = BaseSchema.extend({
/**
* Disclosure Schema Union - All disclosure component schemas
*/
export const DisclosureSchema = z.discriminatedUnion('type', [
const DisclosureSchemaInferred = z.discriminatedUnion('type', [
AccordionSchema,
CollapsibleSchema,
ToggleGroupSchema,
]);

/**
* The TYPE of {@link DisclosureSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface DisclosureZodType extends DisclosureSchemaInferredType {
options: DisclosureSchemaInferredType['options'];
}
type DisclosureSchemaInferredType = typeof DisclosureSchemaInferred;

/** The union above, typed by its named {@link DisclosureZodType}. */
export const DisclosureSchema: DisclosureZodType = DisclosureSchemaInferred;
15 changes: 14 additions & 1 deletion packages/types/src/zod/feedback.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export const SonnerSchema = BaseSchema.extend({
/**
* Feedback Schema Union - All feedback component schemas
*/
export const FeedbackSchema = z.discriminatedUnion('type', [
const FeedbackSchemaInferred = z.discriminatedUnion('type', [
LoadingSchema,
ProgressSchema,
SkeletonSchema,
Expand All @@ -311,3 +311,16 @@ export const FeedbackSchema = z.discriminatedUnion('type', [
EmptySchema,
SonnerSchema,
]);

/**
* The TYPE of {@link FeedbackSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface FeedbackZodType extends FeedbackSchemaInferredType {
options: FeedbackSchemaInferredType['options'];
}
type FeedbackSchemaInferredType = typeof FeedbackSchemaInferred;

/** The union above, typed by its named {@link FeedbackZodType}. */
export const FeedbackSchema: FeedbackZodType = FeedbackSchemaInferred;
15 changes: 14 additions & 1 deletion packages/types/src/zod/form.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ export const CodeEditorSchema = BaseSchema.extend({
children: retirementTombstone(CODE_EDITOR_NEITHER_CHANNEL),
});

export const FormComponentSchema = z.discriminatedUnion('type', [
const FormComponentSchemaInferred = z.discriminatedUnion('type', [
ButtonSchema,
InputSchema,
TextareaSchema,
Expand All @@ -1411,3 +1411,16 @@ export const FormComponentSchema = z.discriminatedUnion('type', [
InputShorthandSchema,
UiCalendarSchema,
]);

/**
* The TYPE of {@link FormComponentSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface FormComponentZodType extends FormComponentSchemaInferredType {
options: FormComponentSchemaInferredType['options'];
}
type FormComponentSchemaInferredType = typeof FormComponentSchemaInferred;

/** The union above, typed by its named {@link FormComponentZodType}. */
export const FormComponentSchema: FormComponentZodType = FormComponentSchemaInferred;
27 changes: 27 additions & 0 deletions packages/types/src/zod/index.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,33 @@ import { nestedComponentJudgment } from './nested-component-walk.js';
* fill is an installation and nothing more. The slot itself is
* still a plain `z.union` in `base.zod.ts` — that is what keeps its option array by
* reference, and it is untouched by the discrimination.
*
* ## Why every category union's TYPE is named (objectui#11573)
*
* `tsc` prints an inferred type in full wherever a declaration uses it, and it
* refuses to print one past its serialization ceiling with TS7056 ("The
* inferred type of this node exceeds the maximum length the compiler will
* serialize"); `@object-ui/types` then emits no declarations at all, and every
* consumer of `./zod` fails with TS7016. This declaration lists the members
* below, so printed inline it is the SUM of every category's print — the
* `Spec Main Shape Gate` caught it crossing the ceiling, and single arms were
* named one TS7056 at a time to stay under it (`AppSchemaRendererNodeSchemaType`,
* `PageKindNodeSchemaType`, `ReportNodeZodType`, `RecordLineItemsBlockSchemaType`)
* until objectui#11573 measured what was left: under one percent of the ceiling.
*
* So every category union listed here has a NAMED type: an exported interface
* in its own module that extends the union's inferred type and adds no member
* (`LayoutZodType`, `PublicBlockComponentZodType` and their siblings). An
* interface is printed by name, so each union's body is printed once, in its
* own module's declaration, and this declaration prints a reference to it. The
* TYPES are unchanged: the value is the union itself, and `z.input` / `z.output`
* read the union's own internals. Only the printed `.d.ts` text moved.
*
* ⚠️ A member added below is printed inline unless its type is named the same
* way. `__tests__/any-component-emit-headroom-11573.test.ts` reads this
* declaration's size with the compiler's own counter, fails when it crosses its
* stated margin below the ceiling, and lists every member as named or inline,
* so a new member turns it red until it is classified there.
*/
export const AnyComponentSchema = defineNodeComponentUnion(z.discriminatedUnion('type', [
AppComponentSchema,
Expand Down
15 changes: 14 additions & 1 deletion packages/types/src/zod/layout.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ export const HtmlElementSchema = BaseSchema.extend({
/**
* Layout Schema Union - All layout component schemas
*/
export const LayoutSchema = z.discriminatedUnion('type', [
const LayoutSchemaInferred = z.discriminatedUnion('type', [
DivSchema,
BoxSchema,
TextSpanSchema,
Expand All @@ -1542,3 +1542,16 @@ export const LayoutSchema = z.discriminatedUnion('type', [
SemanticElementSchema,
HtmlElementSchema,
]);

/**
* The TYPE of {@link LayoutSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface LayoutZodType extends LayoutSchemaInferredType {
options: LayoutSchemaInferredType['options'];
}
type LayoutSchemaInferredType = typeof LayoutSchemaInferred;

/** The union above, typed by its named {@link LayoutZodType}. */
export const LayoutSchema: LayoutZodType = LayoutSchemaInferred;
15 changes: 14 additions & 1 deletion packages/types/src/zod/navigation.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,24 @@ export const ButtonGroupSchema = BaseSchema.extend({
/**
* Navigation Schema Union - All navigation component schemas
*/
export const NavigationSchema = z.discriminatedUnion('type', [
const NavigationSchemaInferred = z.discriminatedUnion('type', [
HeaderBarSchema,
SidebarSchema,
BreadcrumbSchema,
PaginationSchema,
NavigationMenuSchema,
ButtonGroupSchema,
]);

/**
* The TYPE of {@link NavigationSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface NavigationZodType extends NavigationSchemaInferredType {
options: NavigationSchemaInferredType['options'];
}
type NavigationSchemaInferredType = typeof NavigationSchemaInferred;

/** The union above, typed by its named {@link NavigationZodType}. */
export const NavigationSchema: NavigationZodType = NavigationSchemaInferred;
30 changes: 28 additions & 2 deletions packages/types/src/zod/objectql.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4189,7 +4189,7 @@ export const ObjectDataTableSchema = BaseSchema.extend({
* `object-grid` node is armed by `ObjectGridBlockSchema` below, from its spec
* row.
*/
export const ObjectQLComponentSchema = z.discriminatedUnion('type', [
const ObjectQLComponentSchemaInferred = z.discriminatedUnion('type', [
ObjectViewSchema,
ObjectTreeSchema,
ObjectCalendarSchema,
Expand All @@ -4199,6 +4199,19 @@ export const ObjectQLComponentSchema = z.discriminatedUnion('type', [
ListViewSchema,
]);

/**
* The TYPE of {@link ObjectQLComponentSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface ObjectQLComponentZodType extends ObjectQLComponentSchemaInferredType {
options: ObjectQLComponentSchemaInferredType['options'];
}
type ObjectQLComponentSchemaInferredType = typeof ObjectQLComponentSchemaInferred;

/** The union above, typed by its named {@link ObjectQLComponentZodType}. */
export const ObjectQLComponentSchema: ObjectQLComponentZodType = ObjectQLComponentSchemaInferred;

/* ── ADR-0080 public blocks of this family, armed from their spec rows ───── */

// The `properties` member of each block below is `propsBag` from
Expand Down Expand Up @@ -5154,7 +5167,7 @@ export const EmbeddableFormBlockSchema = BaseSchema.extend({
* declaration, not a copy of it. `ObjectGridSchema` and `ObjectChartSchema`
* above spread it too (objectui#10872 batch 9).
*/
export const ObjectQLPublicBlockComponentSchema = z.discriminatedUnion('type', [
const ObjectQLPublicBlockComponentSchemaInferred = z.discriminatedUnion('type', [
ObjectMetricBlockSchema,
ObjectMasterDetailFormBlockSchema,
ObjectTimelineBlockSchema,
Expand All @@ -5167,3 +5180,16 @@ export const ObjectQLPublicBlockComponentSchema = z.discriminatedUnion('type', [
ObjectPivotBlockSchema,
EmbeddableFormBlockSchema,
]);

/**
* The TYPE of {@link ObjectQLPublicBlockComponentSchema}, NAMED so declaration emit prints it by
* reference (objectui#11573): see "Why every category union's TYPE is named"
* on `AnyComponentSchema` (`index.zod.ts`). It adds no member.
*/
export interface ObjectQLPublicBlockComponentZodType extends ObjectQLPublicBlockComponentSchemaInferredType {
options: ObjectQLPublicBlockComponentSchemaInferredType['options'];
}
type ObjectQLPublicBlockComponentSchemaInferredType = typeof ObjectQLPublicBlockComponentSchemaInferred;

/** The union above, typed by its named {@link ObjectQLPublicBlockComponentZodType}. */
export const ObjectQLPublicBlockComponentSchema: ObjectQLPublicBlockComponentZodType = ObjectQLPublicBlockComponentSchemaInferred;
Loading
Loading