From 6f54cf17cffdb292c9cd88b3e3e111b8b01dcc9e Mon Sep 17 00:00:00 2001 From: dougfabris Date: Tue, 26 Nov 2024 16:45:09 -0300 Subject: [PATCH] chore: ts --- packages/ui-avatar/src/components/UserAvatar.tsx | 14 +++++++++++--- packages/ui-contexts/src/AvatarUrlContext.ts | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/ui-avatar/src/components/UserAvatar.tsx b/packages/ui-avatar/src/components/UserAvatar.tsx index 4491a8ba05482..ce15ff8fca096 100644 --- a/packages/ui-avatar/src/components/UserAvatar.tsx +++ b/packages/ui-avatar/src/components/UserAvatar.tsx @@ -4,13 +4,21 @@ import { memo } from 'react'; import type { BaseAvatarProps } from './BaseAvatar'; import BaseAvatar from './BaseAvatar'; -type UserAvatarProps = Omit & { +type UsernameProp = { username: string; - userId?: string; + userId?: never; +}; + +type UserIdProp = { + userId: string; + username?: never; +}; + +type UserAvatarProps = Omit & { etag?: string; url?: string; title?: string; -}; +} & (UsernameProp | UserIdProp); const UserAvatar = ({ username, userId, etag, ...rest }: UserAvatarProps) => { const getUserAvatarPath = useUserAvatarPath(); diff --git a/packages/ui-contexts/src/AvatarUrlContext.ts b/packages/ui-contexts/src/AvatarUrlContext.ts index 1f13e27647205..760c89bc2dc03 100644 --- a/packages/ui-contexts/src/AvatarUrlContext.ts +++ b/packages/ui-contexts/src/AvatarUrlContext.ts @@ -6,7 +6,7 @@ export type AvatarUrlContextValue = { getUserPathAvatar: { (username: string, etag?: string): string; (params: { userId: string; etag?: string }): string; - (params: { username: string; etag?: string }): string; + (params: { username?: string; etag?: string }): string; }; getRoomPathAvatar: (...args: any) => string; };