Skip to content

Fix TS build errors: narrow string literals in CRM example metadata and remove unused import#710

Merged
hotlong merged 2 commits intomainfrom
copilot/fix-typescript-errors
Feb 22, 2026
Merged

Fix TS build errors: narrow string literals in CRM example metadata and remove unused import#710
hotlong merged 2 commits intomainfrom
copilot/fix-typescript-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 21, 2026

@objectstack/spec v3.0.8 Zod schemas expect narrow literal types for discriminated fields (mode, type, aggregate, sortOrder, direction, provider). Plain object declarations widen these to string, causing 20+ TS2322 errors on the console build. One unused useMemo import also triggers TS6133.

Changes

  • useNavPins.ts — Remove unused useMemo import
  • Report files (sales.report.ts, pipeline.report.ts) — as const on type, chart.type, aggregate, sortOrder
  • Page files (3 files) — as const on type
  • Dashboard (crm.dashboard.ts) — as const on widget type, trend direction, data provider, aggregate function
  • Data files (10 files) — as const on mode: 'upsert'

Example

// Before: TS infers `mode: string` → incompatible with `"replace" | "update" | "upsert" | ...`
export const AccountData = {
  object: 'account',
  mode: 'upsert',
  records: [...]
};

// After: literal type preserved
export const AccountData = {
  object: 'account',
  mode: 'upsert' as const,
  records: [...]
};
Original prompt

22:27:55.672 src/hooks/useNavPins.ts(10,44): error TS6133: 'useMemo' is declared but its value is never read.
22:27:55.672 ../../examples/crm/objectstack.config.ts(76,5): error TS2322: Type '{ name: string; label: string; description: string; objectName: string; type: string; columns: ({ field: string; label: string; aggregate?: undefined; } | { field: string; label: string; aggregate: string; })[]; groupingsDown: { ...; }[]; chart: { ...; }; }' is not assignable to type 'Omit<{ name: string; label: string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }; objectName: string; ... 8 more ...; performance?: { ...; } | undefined; }, "name"> & { ...; }'.
22:27:55.672 ../../examples/crm/objectstack.config.ts(77,5): error TS2322: Type '{ name: string; label: string; description: string; objectName: string; type: string; columns: ({ field: string; label: string; aggregate?: undefined; } | { field: string; label: string; aggregate: string; })[]; groupingsDown: { ...; }[]; filter: { ...; }; chart: { ...; }; }' is not assignable to type 'Omit<{ name: string; label: string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }; objectName: string; ... 8 more ...; performance?: { ...; } | undefined; }, "name"> & { ...; }'.
22:27:55.672 ../../examples/crm/objectstack.config.ts(92,5): error TS2322: Type '{ name: string; label: string; type: string; regions: { name: string; components: { type: string; properties: { className: string; children: { type: string; properties: { value: string; className: string; }; }[]; }; }[]; }[]; }' is not assignable to type 'Omit<{ name: string; label: string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }; regions: { name: string; components: { ...; }[]; width?: "small" | ... 3 more ... | undefined; }[]; ... 11 more ...; aria?: { ...; } | undefined; }, "name"> & { .....'.
22:27:55.672 ../../examples/crm/objectstack.config.ts(93,5): error TS2322: Type '{ name: string; label: string; type: string; regions: { name: string; components: { type: string; properties: { className: string; children: { type: string; properties: { value: string; className: string; }; }[]; }; }[]; }[]; }' is not assignable to type 'Omit<{ name: string; label: string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }; regions: { name: string; components: { ...; }[]; width?: "small" | ... 3 more ... | undefined; }[]; ... 11 more ...; aria?: { ...; } | undefined; }, "name"> & { .....'.
22:27:55.673 ../../examples/crm/objectstack.config.ts(94,5): error TS2322: Type '{ name: string; label: string; type: string; regions: { name: string; components: { type: string; properties: { className: string; children: { type: string; properties: { value: string; className: string; }; }[]; }; }[]; }[]; }' is not assignable to type 'Omit<{ name: string; label: string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }; regions: { name: string; components: { ...; }[]; width?: "small" | ... 3 more ... | undefined; }[]; ... 11 more ...; aria?: { ...; } | undefined; }, "name"> & { .....'.
22:27:55.673 ../../examples/crm/objectstack.config.ts(100,5): error TS2322: Type '{ name: string; label: string; widgets: ({ type: string; layout: { x: number; y: number; w: number; h: number; }; options: { label: string; value: string; trend: { value: number; direction: string; label: string; }; ... 4 more ...; columns?: undefined; }; title?: undefined; } | ... 5 more ... | { ...; })[]; }' is not assignable to type '{ name: string; label: string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }; widgets: { layout: { x: number; y: number; w: number; h: number; }; ... 16 more ...; aria?: { ...; } | undefined; }[]; ... 6 more ...; performance?: { ...; } | undefine...'.
22:27:55.673 ../../examples/crm/objectstack.config.ts(109,7): error TS2322: Type '{ object: string; mode: string; records: ({ _id: string; name: string; industry: string; type: string; employees: number; billing_address: string; shipping_address: string; latitude: number; longitude: number; ... 8 more ...; annual_revenue?: undefined; } | { ...; } | { ...; } | { ...; } | { ...; })[]; }' is not assignable to type '{ object: string; records: Record<string, unknown>[]; externalId?: string | undefined; mode?: "replace" | "update" | "upsert" | "insert" | "ignore" | undefined; env?: ("prod" | "dev" | "test")[] | undefined; }'.
22:27:55.673 ../../examples/crm/objectstack.config.ts(110,7): error TS2322: Type '{ object: string; mode: string; records: ({ _id: string; name: string; email: string; phone: string; title: string; department: string; account: string; status: string; priority: string; lead_source: s...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 21, 2026 3:02pm
objectui-demo Ready Ready Preview, Comment Feb 21, 2026 3:02pm
objectui-storybook Ready Ready Preview, Comment Feb 21, 2026 3:02pm

Request Review

…const for literal type narrowing

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TypeScript errors in CRM configuration Fix TS build errors: narrow string literals in CRM example metadata and remove unused import Feb 21, 2026
Copilot AI requested a review from hotlong February 21, 2026 15:00
@hotlong hotlong marked this pull request as ready for review February 22, 2026 01:54
Copilot AI review requested due to automatic review settings February 22, 2026 01:54
@hotlong hotlong merged commit 946ed1e into main Feb 22, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Purpose: This PR fixes TypeScript compilation errors in the CRM example caused by @objectstack/spec v3.0.8 requiring narrow literal types for discriminated union fields. The Zod schemas in the spec package expect specific string literals (e.g., "upsert", "summary", "up") but TypeScript was widening plain object property values to the general string type, causing 20+ TS2322 type errors.

Changes:

  • Removed unused useMemo import from navigation hooks
  • Added as const assertions to all discriminated union fields across metadata files (reports, pages, dashboards, data)
  • Ensured strict type compatibility with @objectstack/spec v3.0.8 Zod schemas

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
apps/console/src/hooks/useNavPins.ts Removed unused useMemo import that was causing TS6133 error
examples/crm/src/reports/sales.report.ts Added as const to report type, column aggregate, sortOrder, and chart type
examples/crm/src/reports/pipeline.report.ts Added as const to report type, column aggregate, sortOrder, and chart type
examples/crm/src/pages/settings.page.ts Added as const to page type field
examples/crm/src/pages/help.page.ts Added as const to page type field
examples/crm/src/pages/getting_started.page.ts Added as const to page type field
examples/crm/src/data/user.data.ts Added as const to data mode field
examples/crm/src/data/project_task.data.ts Added as const to data mode field
examples/crm/src/data/product.data.ts Added as const to data mode field
examples/crm/src/data/order_item.data.ts Added as const to data mode field
examples/crm/src/data/order.data.ts Added as const to data mode field
examples/crm/src/data/opportunity_contact.data.ts Added as const to data mode field
examples/crm/src/data/opportunity.data.ts Added as const to data mode field
examples/crm/src/data/event.data.ts Added as const to data mode field
examples/crm/src/data/contact.data.ts Added as const to data mode field
examples/crm/src/data/account.data.ts Added as const to data mode field
examples/crm/src/dashboards/crm.dashboard.ts Added as const to widget type, trend direction, data provider, and aggregate function fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants