FredrikOseberg / react-chatbot-kit

MIT License
324 stars 154 forks source link

Widgets Compiling with Problems in TypeScript #162

Open tanmayk92 opened 10 months ago

tanmayk92 commented 10 months ago

When adding a Component in Widgets in the config, It is showing error in browser. @FredrikOseberg

Type '{ botName: string; initialMessages: { loading: boolean; widget?: string | undefined; delay?: number | undefined; payload?: any; message: string; type: string; id: number; }[]; widgets: { widgetName: string; widgetFunc: () => JSX.Element; }[]; customStyles: { ...; }; customComponents: { ...; }; }' is not assignable to type 'IConfig'.
  Types of property 'widgets' are incompatible.
    Type '{ widgetName: string; widgetFunc: () => Element; }[]' is not assignable to type 'IWidget[]'.
      Type '{ widgetName: string; widgetFunc: () => Element; }' is missing the following properties from type 'IWidget': props, mapStateToProps
tanmayk92 commented 10 months ago

Just explore some files in the react-chatbot-kit. The properties are not optional and need to be used in the object, Can we change these properties to optional in the interface of IConfig and IWidget

FredrikOseberg commented 10 months ago

Happy to accept a PR to improve the types @tanmayk92. Or you could share a reproducable example so I can take a look.