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.
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
packages/typescontaining all common TypeScript interfaces and types.tsconfig.jsonto output declaration files (.d.ts).This structure leverages npm's workspace support, ensures easy updates to type definitions, and significantly simplifies long-term maintenance.