Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…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
Contributor
There was a problem hiding this comment.
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
useMemoimport from navigation hooks - Added
as constassertions to all discriminated union fields across metadata files (reports, pages, dashboards, data) - Ensured strict type compatibility with
@objectstack/specv3.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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@objectstack/specv3.0.8 Zod schemas expect narrow literal types for discriminated fields (mode,type,aggregate,sortOrder,direction,provider). Plain object declarations widen these tostring, causing 20+ TS2322 errors on the console build. One unuseduseMemoimport also triggers TS6133.Changes
useNavPins.ts— Remove unuseduseMemoimportsales.report.ts,pipeline.report.ts) —as constontype,chart.type,aggregate,sortOrderas constontypecrm.dashboard.ts) —as conston widgettype, trenddirection, dataprovider, aggregatefunctionas constonmode: 'upsert'Example
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.