Closed sebastien-p closed 5 years ago
That's great @sebastien-p If you can put this in a pull request, I ll be more then happy to merge it :)
Merged in #12 for v2.0.0
Hi, thanks for the merge :)
I didn't open a PR because, while using declare module 'cogo-toast'
seems to work, I think the following would be more correct for typings provided by a library:
import { ReactNode, MouseEventHandler } from 'react';
export type Options = Partial<{
hideAfter: number;
position:
| 'top-left'
| 'top-center'
| 'top-right'
| 'bottom-left'
| 'bottom-center'
| 'bottom-right';
heading: string;
icon: ReactNode;
bar: Partial<{
size: string;
style: 'solid' | 'dashed' | 'dotted';
color: string;
}>;
onClick: MouseEventHandler;
}>;
export type HideToastFunction = () => void;
export type Method = {
(message: string, options?: Options & { hideAfter: 0 }): HideToastFunction;
(message: string, options?: Options): Promise<void>;
};
declare namespace toast {
export const loading: Method;
export const success: Method;
export const error: Method;
export const warn: Method;
export const info: Method;
}
export default toast;
Hi, thanks for this project! I integrated it in some app of mine which is coded in React+TypeScript so I had to create my own type definitions file since you don't provide one. Here it is, in case you may be interested: