We can make own Alexa Skill more easily by using TypeScript features.
I think to set generics on attributesManager is better to develop the skill.
How do you think the idea?
Description
This is the first step to define own attributes type.
I want to discuss and get feedback to set a type to the attributesManager.
Usage
const t: RequestHandler = {
canHandle() {
return true
},
handle(handlerInput) {
const attributes = handlerInput.attributesManager.getSessionAttributes<{
name: string,
phone: number
}>()
const name = attributes.name
if (attributes.phone) {
return handlerInput.responseBuilder
.speak(`Hello ${name}! Can I call you?`)
.reprompt('Can I?')
.getResponse()
}
return handlerInput.responseBuilder
.speak(`Hello ${name}. Could you tell me your phone number?`)
.reprompt('Could you tell me your phone number?')
.getResponse()
}
}
Motivation and Context
Now the attributesManager return values is always {[key: string: any}.
But we want to define the type.
Testing
$ lerna --scope ask-sdk-core run gulp -- test
110 passing (117ms)
=============================== Coverage summary ===============================
Statements : 100% ( 351/351 )
Branches : 100% ( 88/88 )
Functions : 96.26% ( 103/107 )
Lines : 100% ( 330/330 )
================================================================================
[10:49:43] Finished 'test' after 2.32 s
lerna success run Ran npm script 'gulp' in 1 package in 3.6s:
lerna success - ask-sdk-core
Screenshots (if appropriate)
We want
Actual
Types of changes
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
[ ] Docs(Add new document content)
[ ] Translate Docs(Translate document content)
Checklist
[x] My code follows the code style of this project
[x] My change requires a change to the documentation
We can make own Alexa Skill more easily by using TypeScript features. I think to set generics on attributesManager is better to develop the skill. How do you think the idea?
Description
This is the first step to define own attributes type. I want to discuss and get feedback to set a type to the attributesManager.
Usage
Motivation and Context
Now the attributesManager return values is always
{[key: string: any}
. But we want to define the type.Testing
Screenshots (if appropriate)
We want
Actual
Types of changes
Checklist
License