Comments (9)
Hey @kabaluk, the typescript definition is on my todo list.
from react-toastify.
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.
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.
from react-toastify.
@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.
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.
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.
In typescript is it possible to do something like:
interface CommonOptions {
...
closeButton?: React.ReactNode|false; // Can be a node or false
...
}
from react-toastify.
Hello,
May I ask for help, please. I wrote the definition file. The types hinting seems to works
I'm wondering why I can't see the shape of the ToastOptions
. Did I miss something?
from react-toastify.
Related Issues (20)
- Error: export 'useSyncExternalStore' (imported as 'r') was not found in 'react' HOT 2
- Attempted import error: 'isValidElement' is not exported from 'react' (imported as 't'). HOT 3
- Position bottom bug HOT 3
- Hide toast instantly without showing them and add them to notificationcenter HOT 1
- Big image and text not toast HOT 1
- toast.update (unexpectedly) requires container id HOT 1
- The toast message is always success even on error HOT 1
- Bug with render the toast
- Issue with Progress Bar Positioning After Update in Safari Version 10
- React 17 support
- persistent toast across pages with next.js 14
- Support for max() and env() functions in older browsers
- fix(demo): the demo's <ToastContainer /> code isn't working with transition
- toast container throws error when autoclose time is up. HOT 5
- bug
- Syntax Error or a Bug in documentation
- transition
- Transition HOT 1
- Inconsistent Notification Stacking with stacked and newestOnTop HOT 1
- how to dismiss immediately without animation? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-toastify.