Create type definitions for native-toast@2.0 (#28855)

* create type definitions for native-toast@2.0

* fix lint / write as external module
This commit is contained in:
Michael Nahkies
2018-09-14 09:31:49 -07:00
committed by Ryan Cavanaugh
parent 5f3d6a6b43
commit 6e1f5ed8f7
4 changed files with 79 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for native-toast 2.0
// Project: https://github.com/egoist/native-toast
// Definitions by: Michael Nahkies <https://github.com/mnahkies>
// 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;
}
+20
View File
@@ -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);
+24
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }