GithubHelp home page GithubHelp logo

Comments (9)

fkhadra avatar fkhadra commented on May 11, 2024 2

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

from react-toastify.

kabaluk avatar kabaluk commented on May 11, 2024 1

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 :)

from react-toastify.

fkhadra avatar fkhadra commented on May 11, 2024

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.

from react-toastify.

kabaluk avatar kabaluk commented on May 11, 2024

from react-toastify.

midori0507 avatar midori0507 commented on May 11, 2024

@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
}

from react-toastify.

talend-jphautin avatar talend-jphautin commented on May 11, 2024

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> {
    }

}

from react-toastify.

fkhadra avatar fkhadra commented on May 11, 2024

Hey @talend-jphautin ,

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

from react-toastify.

fkhadra avatar fkhadra commented on May 11, 2024

In typescript is it possible to do something like:

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

from react-toastify.

fkhadra avatar fkhadra commented on May 11, 2024

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?

from react-toastify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.