Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Fix ask/addQuestion type signatures #1818

Merged
merged 3 commits into from
Oct 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/botkit/src/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export class BotkitConversation<O extends object = {}> extends Dialog<O> {
* @param handlers one or more handler functions defining possible conditional actions based on the response to the question.
* @param key name of variable to store response in.
*/
public ask(message: Partial<BotkitMessageTemplate> | string, handlers: BotkitConvoTrigger | BotkitConvoTrigger[], key: {key: string} | string | null): BotkitConversation {
public ask(message: Partial<BotkitMessageTemplate> | string, handlers: BotkitConvoHandler | BotkitConvoTrigger[], key: {key: string} | string | null): BotkitConversation {
this.addQuestion(message, handlers, key, 'default');
return this;
}
Expand All @@ -343,7 +343,7 @@ export class BotkitConversation<O extends object = {}> extends Dialog<O> {
* @param key Name of variable to store response in.
* @param thread_name Name of thread to which message will be added
*/
public addQuestion(message: Partial<BotkitMessageTemplate> | string, handlers: BotkitConvoTrigger | BotkitConvoTrigger[], key: {key: string} | string | null, thread_name: string): BotkitConversation {
public addQuestion(message: Partial<BotkitMessageTemplate> | string, handlers: BotkitConvoHandler | BotkitConvoTrigger[], key: {key: string} | string | null, thread_name: string): BotkitConversation {
if (!thread_name) {
thread_name = 'default';
}
Expand Down Expand Up @@ -373,6 +373,8 @@ export class BotkitConversation<O extends object = {}> extends Dialog<O> {
handler: handlers
}
];
} else {
throw new Error("Unsupported handlers type: " + typeof (handlers));
}

// ensure all options have a type field
Expand Down Expand Up @@ -773,7 +775,7 @@ export class BotkitConversation<O extends object = {}> extends Dialog<O> {
}

outgoing.channelData = outgoing.channelData ? outgoing.channelData : {};

/*******************************************************************************************************************/
// allow dynamic generation of quick replies and/or attachments
if (typeof(line.quick_replies)=='function') {
Expand Down