From 98b8fc3a977906257ecc35b349e26210f95d7fd3 Mon Sep 17 00:00:00 2001 From: Klaas Cuvelier Date: Thu, 5 Jul 2018 19:09:15 +0200 Subject: [PATCH] Add type definitions for react-notify-toast (#27052) * Add type definitions for react-notify-toast * use 4 spaces * add comments * Fix issues --- types/react-notify-toast/index.d.ts | 33 +++++++++++++++++++ .../react-notify-toast-tests.tsx | 20 +++++++++++ types/react-notify-toast/tsconfig.json | 25 ++++++++++++++ types/react-notify-toast/tslint.json | 1 + 4 files changed, 79 insertions(+) create mode 100644 types/react-notify-toast/index.d.ts create mode 100644 types/react-notify-toast/react-notify-toast-tests.tsx create mode 100644 types/react-notify-toast/tsconfig.json create mode 100644 types/react-notify-toast/tslint.json diff --git a/types/react-notify-toast/index.d.ts b/types/react-notify-toast/index.d.ts new file mode 100644 index 0000000000..689d543ce8 --- /dev/null +++ b/types/react-notify-toast/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for react-notify-toast 0.5 +// Project: https://github.com/jesusoterogomez/react-notify-toast +// Definitions by: Klaas Cuvelier +// 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 {} + +export const notify: reactNotifyToast; +export default Notification; diff --git a/types/react-notify-toast/react-notify-toast-tests.tsx b/types/react-notify-toast/react-notify-toast-tests.tsx new file mode 100644 index 0000000000..38adc837bd --- /dev/null +++ b/types/react-notify-toast/react-notify-toast-tests.tsx @@ -0,0 +1,20 @@ +import * as React from 'react'; +import Notification, { notify } from 'react-notify-toast'; + +export class NotificationTest extends React.Component { + render() { + return(); + } +} + +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(); +} diff --git a/types/react-notify-toast/tsconfig.json b/types/react-notify-toast/tsconfig.json new file mode 100644 index 0000000000..c9c3ff748c --- /dev/null +++ b/types/react-notify-toast/tsconfig.json @@ -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" + ] +} diff --git a/types/react-notify-toast/tslint.json b/types/react-notify-toast/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-notify-toast/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }