diff --git a/types/native-toast/index.d.ts b/types/native-toast/index.d.ts new file mode 100644 index 0000000000..1b9e532255 --- /dev/null +++ b/types/native-toast/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for native-toast 2.0 +// Project: https://github.com/egoist/native-toast +// Definitions by: Michael Nahkies +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare const toast: { + (options: ToastOptions): Toast, + success: (options: ToastOptions) => Toast, + warning: (options: ToastOptions) => Toast, + info: (options: ToastOptions) => Toast, + error: (options: ToastOptions) => Toast, +}; + +export default toast; + +export interface ToastOptions { + message?: string; + position?: "center" | "west" | "east" | "south" | "south-west" | "south-east" | "north" | "north-west" | "north-east"; + timeout?: number; + el?: HTMLElement; + rounded?: boolean; + type?: "success" | "warning" | "info" | "error"; + debug?: boolean; + edge?: boolean; + icon?: boolean; + closeOnClick?: boolean; + elements?: HTMLElement[]; +} + +export interface Toast { + show(): void; + hide(): void; + destroy(): void; +} diff --git a/types/native-toast/native-toast-tests.ts b/types/native-toast/native-toast-tests.ts new file mode 100644 index 0000000000..73d6890549 --- /dev/null +++ b/types/native-toast/native-toast-tests.ts @@ -0,0 +1,20 @@ +import toast, { Toast, ToastOptions } from "native-toast"; + +let t: Toast; + +t = toast({ + message: "Team created", + position: "north-east", + timeout: 5000, + type: "success", +}); + +t.hide(); +t.show(); + +const o: ToastOptions = { + message: "test", + position: "west" +}; + +toast.success(o); diff --git a/types/native-toast/tsconfig.json b/types/native-toast/tsconfig.json new file mode 100644 index 0000000000..d36ee00fd9 --- /dev/null +++ b/types/native-toast/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "native-toast-tests.ts" + ] +} diff --git a/types/native-toast/tslint.json b/types/native-toast/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/native-toast/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }