Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate types instead of generic types #181

Open
brichet opened this issue Feb 17, 2025 · 0 comments
Open

Use separate types instead of generic types #181

brichet opened this issue Feb 17, 2025 · 0 comments

Comments

@brichet
Copy link
Collaborator

brichet commented Feb 17, 2025

Generic types can cause a lot of complex TypeScript errors that are difficult to resolve, so I recommend we avoid them unless they are necessary. This seems equivalent & easier to maintain:

interface IBaseChatMessage {
  type: 'msg';
  body: string;
  id: string;
  time: number;
  sender: unknown;
  attachments?: unknown[];
}

/**
 * The interface of a chat message in the chat model.
 */
export interface IChatMessage extends IBaseChatMessage {
  sender: IUser;
  attachments?: IAttachment[];
}

/**
 * The interface of a chat message in the YChat shared document.
 */
export interface IYMessage extends IBaseChatMessage {
  sender: string;
  attachments?: string[];
}

Originally posted by @dlqqq in #148 (comment)

For the context, this would be in replacement of the IChatMessage interface and the IYMessage interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant