pusher-redux icon indicating copy to clipboard operation
pusher-redux copied to clipboard

Typescript Support

Open tristanhcole opened this issue 4 years ago • 4 comments

Is it possible to add types to this package?

tristanhcole avatar Jun 25 '20 05:06 tristanhcole

I started drafting up something like this for an index.d.ts file.... new to typescript... would love some feedback/help on this.

import { StoreCreator } from 'redux'
import Options from 'pusher-js/src/core/options'
import Pusher from 'pusher-js/src/core/pusher'

declare module "pusher-redux" {
    export function setPusherClient(
        PusherClient: Pusher
    ): any;

    export function configurePusher(
        store: StoreCreator,
        apiKey: string,
        options?: Options
    ): any;

    export function delayConfiguration(
        store: StoreCreator,
        apiKey: string,
        options?: Options
    ): any;

    export function startConfiguration(
        options?: Options
    ): any;

    export function subscribe(
        channelName: string,
        eventName: string,
        actionType: string,
        additionalParams: any
    ): any;

    export function unsubscribe(
        channelName: string,
        eventName: string,
        actionType: string,
    ): any;

    export function getChannel(
        channelName: string
    ): any;

    export function disconnect(): any;

    let CONNECTED: string;
    let DISCONNECTED: string;
    let CONNECTING: string;
    let UNAVAILABLE: string;
    let FAILED: string;
}```

tristanhcole avatar Jun 25 '20 06:06 tristanhcole

hey @tristanhcole thanks for this effort! I am a bit swamped with other work lately and don't have a current project that uses pusher-redux to test it on.

As for your code it's a great start, it can be polished further of course, but hopefully, you and others find it useful already. I don't think I can merge this yet, but these typings can be used separately from this repo.

TheRusskiy avatar Jun 25 '20 20:06 TheRusskiy

hey @tristanhcole thanks for this effort! I am a bit swamped with other work lately and don't have a current project that uses pusher-redux to test it on.

As for your code it's a great start, it can be polished further of course, but hopefully, you and others find it useful already. I don't think I can merge this yet, but these typings can be used separately from this repo.

No worries @TheRusskiy! Thanks for the reply. I'll try to improve the typing of these and put in a PR once it's further along

tristanhcole avatar Jun 26 '20 05:06 tristanhcole

@tristanhcole any updates on the TS support?

devinrhode2 avatar Aug 31 '22 14:08 devinrhode2