fix: resolve TypeScript build errors in console app#1197
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- objectDetailWidgets.tsx: pass required `index` arg to toObjectDefinition() - ObjectManagerListAdapter.tsx: remove unused MetadataObject import - SystemHubPage.tsx: remove unused LayoutGrid import - SystemHubPage.tsx: widen HubCard.icon type to React.ElementType - metadataConverters.ts: cast relationship type to proper union type Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/acfc66f8-324c-4b4b-bdeb-08a5b6f52fd6 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/acfc66f8-324c-4b4b-bdeb-08a5b6f52fd6 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes TypeScript build failures in the apps/console app by aligning console-side typings and call sites with the expected @object-ui/types interfaces and utility return types.
Changes:
- Fix
toObjectDefinition()usage by passing the requiredindexargument for single-object conversion. - Remove unused imports that were causing TypeScript/ESLint noise.
- Adjust hub card icon typing to match
getIcon()’s return type and satisfy the compiler. - Update relationship
typeconversion to satisfyObjectDefinitionRelationship['type']constraints.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/console/src/utils/metadataConverters.ts | Updates relationship type conversion to satisfy the ObjectDefinitionRelationship union typing. |
| apps/console/src/pages/system/SystemHubPage.tsx | Removes an unused icon import and widens HubCard.icon typing to accommodate getIcon() results. |
| apps/console/src/components/schema/objectDetailWidgets.tsx | Fixes a missing required argument when converting a single metadata object to ObjectDefinition. |
| apps/console/src/components/ObjectManagerListAdapter.tsx | Removes an unused MetadataObject import from the converters module import list. |
| ? obj.relationships.map((r) => ({ | ||
| relatedObject: r.object || r.relatedObject || '', | ||
| type: r.type || 'one-to-many', | ||
| type: (r.type || 'one-to-many') as ObjectDefinitionRelationship['type'], | ||
| label: r.label || r.name || undefined, | ||
| foreignKey: r.foreign_key || r.foreignKey || undefined, |
There was a problem hiding this comment.
Casting r.type to ObjectDefinitionRelationship['type'] bypasses the union constraint at compile-time and can let unexpected API values flow into ObjectDefinition.relationships. Consider normalizing/validating r.type against the allowed set ('one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many') and falling back to 'one-to-many' when it’s not one of those, instead of a blind type assertion.
| interface HubCard { | ||
| title: string; | ||
| description: string; | ||
| icon: React.ComponentType<{ className?: string }>; | ||
| icon: React.ElementType; | ||
| href: string; |
There was a problem hiding this comment.
HubCard.icon was widened to React.ElementType, but the rendering code uses <Icon className="..." />. ElementType doesn’t guarantee the component accepts className, so this reduces type safety and can mask icon incompatibilities. Prefer a more specific icon type (e.g., LucideIcon from lucide-react or React.ComponentType<{ className?: string }>), and adjust getIcon()’s return type accordingly so call sites stay type-safe.
Five TypeScript errors in
apps/consolewere failing the CI build (Build Corejob). Tests were already passing.objectDetailWidgets.tsx—toObjectDefinition(metadataObject)missing requiredindexarg; added0for single-object lookupObjectManagerListAdapter.tsx— removed unusedMetadataObjectimportSystemHubPage.tsx— removed unusedLayoutGridimport; widenedHubCard.iconfromReact.ComponentType<{className?: string}>toReact.ElementTypeto matchgetIcon()return typemetadataConverters.ts— relationshiptypefield wasstring, now asserted asObjectDefinitionRelationship['type']to satisfy the union constraint