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

Fix dynamic text field type definition #1960

Merged
merged 1 commit into from
May 20, 2020

Conversation

etiennellipse
Copy link
Contributor

See BotkitConversation.makeOutgoing method.

The text variable must be a string, as it is fed into the mustache renderer here. So the template function must always return a string, or the function will crash later on.

Therefore, the type definition must reflect that. I am getting TypeScript error when returning a string, if I can it to an array, botkit breaks. 😞

@benbrown
Copy link
Contributor

If specified as an array, the function will pick one at random. What breaks if you do this?

@etiennellipse
Copy link
Contributor Author

@benbrown It works as expected, no problem with that.

The issue is when passing a function with a template, the function must return only one string (and not an array). It is how botkit works, but the type definition does not reflect that correctly. So when using Botkit with a TypeScript project, the type checker screams.

@benbrown
Copy link
Contributor

oh i see, only when applied to the FUNCTIONS. got it! Merging!

@benbrown benbrown merged commit 3fe92d7 into howdyai:master May 20, 2020
@etiennellipse etiennellipse deleted the messagetemplate-type branch May 20, 2020 20:43
@etiennellipse
Copy link
Contributor Author

Yeah, sorry it was not clear in my PR description now that I read it again.

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

Successfully merging this pull request may close these issues.

2 participants