Skip to content

Type mismatch: CollectionInfo missing 'public' property causes TypeScript errors in charts-core #2908

@sykp241095

Description

@sykp241095

Bug Description

There is a type mismatch between CollectionInfo and the expected type in LinkedData.collections, causing TypeScript compilation errors in the charts-core module.

Affected Files

  1. components/ui/components/CollectionSelector/CollectionSelector.tsx (Line 5-8)

    • CollectionInfo type only defines id and name properties
  2. lib/charts-core/parameters/resolver.ts (Lines 106, 109)

    • Code assigns objects with public property to linkedData.collections
    • Creates fallback object: { id: parseInt(param), public: false, name: 'Unknown' }
  3. lib/charts-core/parameters/react/collection-id/index.tsx (Line 12)

    • Error: Property 'public' is missing in type 'CollectionInfo'

TypeScript Errors

lib/charts-core/parameters/react/collection-id/index.tsx(12,7): error TS2741: Property 'public' is missing in type 'CollectionInfo' but required in type '{ id: number; name: string; public: boolean; }'.
lib/charts-core/parameters/resolver.ts(106,18): error TS2322: Type 'Promise<Collection | { id: number; public: false; name: string; }>' is not assignable to type 'Promise<{ id: number; name: string; public: boolean; }>'.

Root Cause

The LinkedData type in lib/charts-core/parameters/resolver.ts defines:

collections: Record<string, { id: number, name: string, public: boolean }>

But CollectionInfo in CollectionSelector.tsx only has:

export type CollectionInfo = {
  id: number;
  name: string;
};

Suggested Fix

Option 1: Add public property to CollectionInfo:

export type CollectionInfo = {
  id: number;
  name: string;
  public?: boolean;  // Make optional since API doesn't always return it
};

Option 2: Update the API response to include public property and modify searchCollections to fetch it.

Impact

  • Prevents strict TypeScript compilation
  • Type safety is compromised in collection-related code
  • May hide other type-related bugs

Priority

Medium - Doesn't cause runtime errors (JavaScript ignores extra properties) but reduces type safety and code quality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions