tawk / tawk-messenger-react

Official React plugin for Tawk messenger
https://www.tawk.to
Other
23 stars 15 forks source link

Incompatible with typescript #13

Open Mancunia opened 2 years ago

Mancunia commented 2 years ago

I want to integrate it into my next js with typescript app, and typescript is giving me tough time

jaoaustero commented 2 years ago

@Mancunia Our plugin isn't yet typescript supported. This was on our backlog and currently migrating our widget to typescript. This will be next, ETA would be around last quarter. You can temporary declare types in your project by defining this library or add into ts-ignore to avoid having error for missing type declarations.

KesleyDavid commented 7 months ago

To solve it, add the file to your project and it will work File: tawk-to-tawk-messenger-react.d.ts

Content:

declare module '@tawk.to/tawk-messenger-react' {
  const TawkMessengerReact: any
  export default TawkMessengerReact
}
jsgv commented 2 months ago

An improved type definition

import * as React from "react";

declare module "@tawk.to/tawk-messenger-react" {
    type Props = {
        propertyId: string;
        widgetId: string;
    };

    export default class TawkMessengerReact extends React.Component<Props> {}
}

And you can also add any additional props you are interested in.