Add type definitions for react-notify-toast (#27052)

* Add type definitions for react-notify-toast

* use 4 spaces

* add comments

* Fix issues
This commit is contained in:
Klaas Cuvelier 2018-07-05 19:09:15 +02:00 committed by Mohamed Hegazy
parent f83dee6c0e
commit 98b8fc3a97
4 changed files with 79 additions and 0 deletions

33
types/react-notify-toast/index.d.ts vendored Normal file
View File

@ -0,0 +1,33 @@
// Type definitions for react-notify-toast 0.5
// Project: https://github.com/jesusoterogomez/react-notify-toast
// Definitions by: Klaas Cuvelier <https://github.com/klaascuvelier>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from 'react';
interface reactNotifyToastColor {
background: string;
text: string;
}
declare class reactNotifyToast {
show(
text: string,
type?: 'success' | 'error' | 'warning' | 'custom',
timeout?: number,
color?: reactNotifyToastColor
): void;
hide(): void;
createShowQueue(): reactNotifyToast;
}
interface NotificationProps {
options: any;
}
export class Notification extends React.Component<NotificationProps, any> {}
export const notify: reactNotifyToast;
export default Notification;

View File

@ -0,0 +1,20 @@
import * as React from 'react';
import Notification, { notify } from 'react-notify-toast';
export class NotificationTest extends React.Component {
render() {
return(<Notification options={{zIndex: 200, top: '15px'}} />);
}
}
function testNotify() {
notify.show('show something');
notify.show('show error', 'error');
notify.show('show warning', 'warning', 100);
const queue = notify.createShowQueue();
queue.show('hi');
queue.show('test');
notify.hide();
}

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"react-notify-toast-tests.tsx"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }