When working with an external library, I often find myself needing to add new properties to passed-in parameters. Instead of using (<any>conv.data)
due to the compiler error Object is of type 'unknown'
, I'm curious if there's a more effective approach for achieving this.
Any suggestions on how to improve this process?
import { dialogflow, Permission } from 'actions-on-google';
const app = dialogflow({ debug: true });
app.intent('actions_intent_PERMISSION', (conv, _, permissionGranted) => {
if (!permissionGranted) {
conv.ask('Bye Bye!')
} else {
(<any>conv.data).userName = conv.user.name.display
conv.ask(`Thanks, ${(<any>conv.data).userName}.`)
}
})