I'm familiar with the behaviour of this inside an arrow function in typescript (or at least I thought so).
However today I stumbled across a this being used in the arguments list of an arrow function (this is from the type definitions of the alexa-sdk):
export interface Handlers<T> {
[intent: string]: (this: Handler<T>) => void;
}
What does this actually mean and how would I implement this?
let handlers: Handlers<IntentRequest> = {
"MyIntent" = ???
}
I know that I can do something like:
let handlers: Handlers<IntentRequest> = {
"MyIntent" = function() {
let self: Alexa.Handler<IntentRequest> = this;
}
}
but is there a more elegant solution without the self/this assignment with a arrow function?
this parameterssection here: typescriptlang.org/docs/handbook/functions.html