React-toastify: Would you be so kind to publish typings for this?

Created on 26 Jun 2017  Â·  9Comments  Â·  Source: fkhadra/react-toastify

Really wanted to use this with Typescript.
Would be really nice if you could add Typings and publish to @types

feature

Most helpful comment

Hey @kabaluk, the typescript definition is on my todo list.

All 9 comments

Hello @kabaluk,

I have to rewrite the lib using Typescript or is just something like typescript definition?
I don't know too much about typescript ecosystem.

just the typecript definition would suffice and be very appreciated I am sure.

On Tuesday, 27 June 2017, 11:52, Fadi Khadra <[email protected]> wrote:

Hello @kabaluk,I have to rewrite the lib using Typescript or is just something like typescript definition?
I don't know too much about typescript ecosystem.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@kabaluk just create custom typing for it, in types folder under rootDir, have folder with react-toastify and index.d.ts inside

For example i only use ToastContainer and toast

declare module 'react-toastify' {
    const content: any 
    export const ToastContainer: any
    export const toast: any
    export default content
}

Hey @kabaluk, the typescript definition is on my todo list.

the one I am using until the official one. not perfect but could be a good start.

declare module 'react-toastify' {

    export let toast:Toast;

    interface Toast {
        success(content:React.ReactNode, options?:ToastOptions):number
        info(content:React.ReactNode, options?:ToastOptions):number
        warn(content:React.ReactNode, options?:ToastOptions):number
        error(content:React.ReactNode, options?:ToastOptions):number
        isActive(toastId:number):boolean;
        dismiss(toastId:number):void;
        (content:React.ReactNode, options?:ToastOptions):void
    }

    interface CommonOptions {
        pauseOnHover?:boolean;
        closeOnClick?:boolean;
        autoClose?:number;
        position?:string;

    }

    interface ToastOptions extends CommonOptions {
        onOpen?:() => void;
        onClose?:() => void;
        closeButton?:React.ReactNode;
        className?:string;
        progressClassName?:string;
        pauseOnHover?:boolean;
        closeOnClick?:boolean;
    }

    interface ToastContainerProps extends CommonOptions {
        type?:string
        hideProgressBar?:boolean;
        newestOnTop?:boolean;
    }

    export class ToastContainer extends React.Component<ToastContainerProps> {
    }

}

Hey @talend-jphautin ,

I appreciate a lot! Merci 😀 . It's definitely a good start. I'll work on it this weekend. Thank you again.

Heya.
We did end up auto generating one with dts-gen.
But the tool is not great and everything is any which kind beats the point.
the one from @talend-jphautin seems much nicer.

Thanks all for this.

PS: @fkhadra Great Toast mate :)

In typescript is it possible to do something like:

interface CommonOptions {
...
    closeButton?: React.ReactNode|false; // Can be a node or false
...
}

Hello,

May I ask for help, please. I wrote the definition file. The types hinting seems to works
type hinting

I'm wondering why I can't see the shape of the ToastOptions. Did I miss something?

Was this page helpful?
0 / 5 - 0 ratings