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

TypeScript Proposal: Default types for TConvData and TUserStorage should be defined

Open afirstenberg opened this issue 7 years ago • 3 comments

Issue #188 illustrates a general problem with assigning properties to the default TConvData type. TUserStorage appears to have the same problem based on this StackOverflow question. The issue is that the definition of DialogflowConversation defines these as type {}, and TypeScripts type checking doesn't allow for properties that aren't defined.

The TypeScript Handbook seems to suggest that creating an interface that explicitly allows any property of any type is a way to work around this issue

interface GenericStorage {
    [propName: string]: any;
}

afirstenberg avatar Nov 27 '18 11:11 afirstenberg

I agree

thomasvt1 avatar Dec 07 '18 10:12 thomasvt1

Originally, it was intended to be empty by default to make developers have to define their own types for stricter type control.

But maybe it makes more sense to provide convenience first and have developers optionally make their types stricter.

We can take a look at this again and possibly change the behavior.

Canain avatar Mar 25 '19 19:03 Canain

This has been fixed and can be closed. JsonObject is used as default type (see src/dialogflow/conv.ts)

maiermic avatar Jul 22 '19 19:07 maiermic