mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
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:
committed by
Ryan Cavanaugh
parent
5f3d6a6b43
commit
6e1f5ed8f7
Vendored
+34
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user