actions-on-google-nodejs icon indicating copy to clipboard operation
actions-on-google-nodejs copied to clipboard

TypeScript : app.middleware does not allow customized types for TConvData and TUserStorage

Open thomasvt1 opened this issue 7 years ago • 0 comments

app.middleware does not allow custom types for TConvData and TUserStorage causing the following error in my IDE;

[ts] Argument of type '(conv: DialogflowConversation<IConvData, IUserStorage, Contexts>) => void' is not assignable to parameter of type 'DialogflowMiddleware<DialogflowConversation<{}, {}, Contexts>>'. Types of parameters 'conv' and 'conv' are incompatible. Type 'DialogflowConversation<{}, {}, Contexts>' is not assignable to type 'DialogflowConversation<IConvData, IUserStorage, Contexts>'. Types of property 'data' are incompatible. Type '{}' is not assignable to type 'IConvData'. [2345] (alias) class DialogflowConversation<TConvData = {}, TUserStorage = {}, TContexts extends Contexts = Contexts> import DialogflowConversation

example code: app.middleware((conv: DialogflowConversation<IConvData, IUserStorage>) => {} causes errors

app.middleware((conv: DialogflowConversation) => {) works just fine but causes errors when accessing conv.data.sample

app.intent works fine using conv: DialogflowConversation<IConvData, IUserStorage>.

thomasvt1 avatar Dec 07 '18 12:12 thomasvt1