Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants