Skip to content

new-webui / log-viewer-webui: Add shared type definitions package for client and server #822

@junhaoliao

Description

@junhaoliao

Request

We currently maintain separate type definitions within our client and server components, leading to potential inconsistencies. To improve maintainability, reduce duplication, and ensure consistency across the project, we should introduce a shared types package using npm workspaces.

Possible implementation

  • Reorganize client and server packages under a common packages/ directory:
    packages/
      ├── client
      ├── server
      └── types
    
  • Create a new workspace package at packages/types containing all common TypeScript interfaces and types.
  • Configure the shared types package with its own tsconfig.json to output declaration files (.d.ts).
  • Utilize npm workspaces to reference this shared package in both the client and server packages:
    npm install @project/types -w client
    npm install @project/types -w server
    
  • Refactor existing client and server codebases to import from @project/types:
    import { User } from '@project/types';
    

This structure leverages npm's workspace support, ensures easy updates to type definitions, and significantly simplifies long-term maintenance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions