Skip to content

Commit 4149d81

Browse files
authored
Remove requirement for ReceivedChatMessage to have an explicit type key (#1241)
1 parent fb3ec22 commit 4149d81

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

.changeset/honest-needles-throw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@livekit/components-core': patch
3+
---
4+
5+
Remove requirement for ReceivedChatMessage to have an explicit type key

packages/core/etc/components-core.api.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,9 @@ export type ReceivedAgentTranscriptionMessage = ReceivedMessageWithType<'agentTr
433433
}>;
434434

435435
// @public (undocumented)
436-
export type ReceivedChatMessage = ReceivedMessageWithType<'chatMessage', ChatMessage & {
437-
from?: Participant;
438-
attributes?: Record<string, string>;
439-
}>;
436+
export type ReceivedChatMessage = Omit<ReceivedChatMessageWithRequiredType, 'type'> & {
437+
type?: 'chatMessage';
438+
};
440439

441440
// @public (undocumented)
442441
export interface ReceivedDataMessage<T extends string | undefined = string> extends BaseDataMessage<T> {

packages/core/src/messages/types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ type ReceivedMessageWithType<Type extends string, Metadata extends object = obje
1515
attributes?: Record<string, string>;
1616
} & Metadata;
1717

18-
/** @public */
19-
export type ReceivedChatMessage = ReceivedMessageWithType<
18+
/** @private */
19+
type ReceivedChatMessageWithRequiredType = ReceivedMessageWithType<
2020
'chatMessage',
2121
ChatMessage & {
2222
from?: Participant;
2323
attributes?: Record<string, string>;
2424
}
2525
>;
2626

27+
/** @public */
28+
export type ReceivedChatMessage = Omit<ReceivedChatMessageWithRequiredType, 'type'> & {
29+
type?: 'chatMessage';
30+
};
31+
2732
export type ReceivedUserTranscriptionMessage = ReceivedMessageWithType<
2833
'userTranscript',
2934
{

0 commit comments

Comments
 (0)