summaryrefslogtreecommitdiff
path: root/cli/dts/lib.deno.window.d.ts
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2020-10-13 22:31:59 +0900
committerGitHub <noreply@github.com>2020-10-13 15:31:59 +0200
commit0dcaea72aeec52a566764b41b10d8fd1854d6fa4 (patch)
tree1c1bfe56b3ac846e83fae48ed5546116d3aea05d /cli/dts/lib.deno.window.d.ts
parent0bd3cea0ff6d2d4840c0df2938b5ae5c5d7cc4bd (diff)
feat: add alert, confirm, and prompt (#7507)
This commit adds "alert", "confirm" and "prompt" functions from web standards.
Diffstat (limited to 'cli/dts/lib.deno.window.d.ts')
-rw-r--r--cli/dts/lib.deno.window.d.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/dts/lib.deno.window.d.ts b/cli/dts/lib.deno.window.d.ts
index 03341636f..541eee370 100644
--- a/cli/dts/lib.deno.window.d.ts
+++ b/cli/dts/lib.deno.window.d.ts
@@ -15,6 +15,9 @@ declare class Window extends EventTarget {
onunload: ((this: Window, ev: Event) => any) | null;
close: () => void;
readonly closed: boolean;
+ alert: (message?: string) => void;
+ confirm: (message?: string) => boolean;
+ prompt: (message?: string, defaultValue?: string) => string | null;
Deno: typeof Deno;
}
@@ -23,4 +26,30 @@ declare var self: Window & typeof globalThis;
declare var onload: ((this: Window, ev: Event) => any) | null;
declare var onunload: ((this: Window, ev: Event) => any) | null;
+/**
+ * Shows the given message and waits for the enter key pressed.
+ * If the stdin is not interactive, it does nothing.
+ * @param message
+ */
+declare function alert(message?: string): void;
+
+/**
+ * Shows the given message and waits for the answer. Returns the user's answer as boolean.
+ * Only `y` and `Y` are considered as true.
+ * If the stdin is not interactive, it returns false.
+ * @param message
+ */
+declare function confirm(message?: string): boolean;
+
+/**
+ * Shows the given message and waits for the user's input. Returns the user's input as string.
+ * If the default value is given and the user inputs the empty string, then it returns the given
+ * default value.
+ * If the default value is not given and the user inputs the empty string, it returns null.
+ * If the stdin is not interactive, it returns null.
+ * @param message
+ * @param defaultValue
+ */
+declare function prompt(message?: string, defaultValue?: string): string | null;
+
/* eslint-enable @typescript-eslint/no-explicit-any */