Skip to content

Commit 3239b88

Browse files
marker-daomarker dao ®
andauthored
Chat: Improve MessageBase.type typings (#34048)
Co-authored-by: marker dao ® <youdontknow@marker-dao.eth>
1 parent 9c7ab4c commit 3239b88

9 files changed

Lines changed: 30 additions & 17 deletions

File tree

packages/devextreme-angular/src/ui/chat/nested/chat-item-dxi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414

1515

1616

17-
import type { Attachment, User } from 'devextreme/ui/chat';
17+
import type { Attachment, User, MessageType } from 'devextreme/ui/chat';
1818

1919
import {
2020
DxIntegrationModule,
@@ -119,10 +119,10 @@ export class DxiChatChatItemComponent extends CollectionNestedOption {
119119
}
120120

121121
@Input()
122-
get type(): string | undefined {
122+
get type(): MessageType {
123123
return this._getOption('type');
124124
}
125-
set type(value: string | undefined) {
125+
set type(value: MessageType) {
126126
this._setOption('type', value);
127127
}
128128

packages/devextreme-angular/src/ui/chat/nested/item-dxi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { DOCUMENT } from '@angular/common';
1919

2020

21-
import type { Attachment, User } from 'devextreme/ui/chat';
21+
import type { Attachment, User, MessageType } from 'devextreme/ui/chat';
2222
import type { ButtonType } from 'devextreme/common';
2323

2424
import {
@@ -130,10 +130,10 @@ export class DxiChatItemComponent extends CollectionNestedOption implements Afte
130130
}
131131

132132
@Input()
133-
get type(): string | undefined | ButtonType {
133+
get type(): MessageType | ButtonType | string {
134134
return this._getOption('type');
135135
}
136-
set type(value: string | undefined | ButtonType) {
136+
set type(value: MessageType | ButtonType | string) {
137137
this._setOption('type', value);
138138
}
139139

packages/devextreme-angular/src/ui/nested/base/button-group-item-dxi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ export abstract class DxiButtonGroupItem extends CollectionNestedOption {
9898
this._setOption('stylingMode', value);
9999
}
100100

101-
get type(): ButtonType | string | undefined {
101+
get type(): ButtonType | string {
102102
return this._getOption('type');
103103
}
104-
set type(value: ButtonType | string | undefined) {
104+
set type(value: ButtonType | string) {
105105
this._setOption('type', value);
106106
}
107107

packages/devextreme-metadata/make-angular-metadata.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Ng.makeMetadata({
5151
removeMembers(/\/grids:AIAssistant/),
5252
removeMembers(/\/calendar:dxCalendarOptions.todayButtonText/),
5353
removeMembers(/\/card_view:/),
54+
removeMembers(/\/chat:MessageType/),
55+
removeMembers(/\/chat:MessageBase.type/),
5456
removeMembers(/\/chat:TextMessage.attachments/),
5557
removeMembers(
5658
/\/chat:dxChatOptions\.(fileUploaderOptions|inputFieldText|sendButtonOptions|speechToTextOptions|suggestions|onAttachmentDownloadClick)/,

packages/devextreme-react/src/chat.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dxChat, {
88
import { Component as BaseComponent, IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
99
import NestedOption from "./core/nested-option";
1010

11-
import type { Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, TypingEndEvent, TypingStartEvent, Attachment as ChatAttachment, User as ChatUser, SendButtonAction, SendButtonClickEvent } from "devextreme/ui/chat";
11+
import type { Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, TypingEndEvent, TypingStartEvent, Attachment as ChatAttachment, User as ChatUser, MessageType, SendButtonAction, SendButtonClickEvent } from "devextreme/ui/chat";
1212
import type { DisposingEvent as FileUploaderDisposingEvent, InitializedEvent as FileUploaderInitializedEvent, BeforeSendEvent, ContentReadyEvent, DropZoneEnterEvent, DropZoneLeaveEvent, FilesUploadedEvent, OptionChangedEvent, ProgressEvent, UploadAbortedEvent, UploadedEvent, UploadErrorEvent, UploadStartedEvent, ValueChangedEvent, UploadHttpMethod, FileUploadMode } from "devextreme/ui/file_uploader";
1313
import type { DisposingEvent as SpeechToTextDisposingEvent, InitializedEvent as SpeechToTextInitializedEvent, ContentReadyEvent as SpeechToTextContentReadyEvent, OptionChangedEvent as SpeechToTextOptionChangedEvent, CustomSpeechRecognizer as SpeechToTextCustomSpeechRecognizer, EndEvent, ErrorEvent, ResultEvent, StartClickEvent, StopClickEvent, SpeechRecognitionConfig as SpeechToTextSpeechRecognitionConfig } from "devextreme/ui/speech_to_text";
1414
import type { DisposingEvent as ButtonGroupDisposingEvent, InitializedEvent as ButtonGroupInitializedEvent, ContentReadyEvent as ButtonGroupContentReadyEvent, OptionChangedEvent as ButtonGroupOptionChangedEvent, dxButtonGroupItem, ItemClickEvent, SelectionChangedEvent } from "devextreme/ui/button_group";
@@ -187,7 +187,7 @@ type IChatItemProps = React.PropsWithChildren<{
187187
src?: string;
188188
text?: string;
189189
timestamp?: Date | number | string;
190-
type?: string | undefined;
190+
type?: MessageType;
191191
}>
192192
const _componentChatItem = (props: IChatItemProps) => {
193193
return React.createElement(NestedOption<IChatItemProps>, {
@@ -367,7 +367,7 @@ type IItemProps = React.PropsWithChildren<{
367367
src?: string;
368368
text?: string;
369369
timestamp?: Date | number | string;
370-
type?: string | undefined | ButtonType;
370+
type?: MessageType | ButtonType | string;
371371
disabled?: boolean;
372372
elementAttr?: Record<string, any>;
373373
hint?: string;

packages/devextreme-vue/src/chat.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
SendButtonProperties,
2626
User,
2727
Attachment,
28+
MessageType,
2829
SendButtonAction,
2930
SendButtonClickEvent,
3031
} from "devextreme/ui/chat";
@@ -359,7 +360,7 @@ const DxChatItemConfig = {
359360
src: String,
360361
text: String,
361362
timestamp: [Date, Number, String],
362-
type: String
363+
type: String as PropType<MessageType>
363364
}
364365
};
365366

@@ -618,7 +619,7 @@ const DxItemConfig = {
618619
template: {},
619620
text: String,
620621
timestamp: [Date, Number, String],
621-
type: String as PropType<string | ButtonType>,
622+
type: String as PropType<MessageType | ButtonType | string>,
622623
visible: Boolean
623624
}
624625
};

packages/devextreme/js/ui/chat.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ export type Attachment = {
249249
[key: string]: any;
250250
};
251251

252+
/**
253+
* @docid
254+
* @namespace DevExpress.ui.dxChat
255+
* @public
256+
*/
257+
export type MessageType = 'text' | 'image';
258+
252259
/**
253260
* @docid
254261
* @namespace DevExpress.ui.dxChat
@@ -263,11 +270,9 @@ export type MessageBase = {
263270
id?: number | string;
264271
/**
265272
* @docid
266-
* @default undefined
267-
* @type string|undefined
268273
* @public
269274
*/
270-
type?: 'text' | 'image' | undefined;
275+
type?: MessageType;
271276
/**
272277
* @docid
273278
* @public

packages/devextreme/js/ui/chat_types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export {
1717
User,
1818
Alert,
1919
Attachment,
20+
MessageType,
2021
TextMessage,
2122
ImageMessage,
2223
Message,

packages/devextreme/ts/dx.all.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34518,7 +34518,7 @@ declare module DevExpress.ui.dxChat {
3451834518
/**
3451934519
* [descr:MessageBase.type]
3452034520
*/
34521-
type?: 'text' | 'image' | undefined;
34521+
type?: MessageType;
3452234522
/**
3452334523
* [descr:MessageBase.timestamp]
3452434524
*/
@@ -34534,6 +34534,10 @@ declare module DevExpress.ui.dxChat {
3453434534

3453534535
[key: string]: any;
3453634536
};
34537+
/**
34538+
* [descr:MessageType]
34539+
*/
34540+
export type MessageType = 'text' | 'image';
3453734541
/**
3453834542
* [descr:SendButtonProperties]
3453934543
*/

0 commit comments

Comments
 (0)