Search code examples
javascriptreactjstypescriptdeclarationcountly-analytics

Declary Countly.q.push inside Typescript declaration file


How I can declare Countly push add_event method like this:

Countly.q.push(['add_event',{
  "key":"action_open_web",
}]);

inside declaration file (.d.ts). I tried this and does not work:

declare module 'countly-sdk-web' {
    export function q.push(
        [string, {key: string,}]
    ): void;
}

Reference: Countly-sdk-web


Solution

  • Something like this?

    declare module 'countly-sdk-web' {
        type Event = [string, Record<string, string>]
        interface ICountly {
            q: Array<Event>
        }
        const Countly: ICountly
        export default Countly;
    }