mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-30 17:48:50 +02:00
type: add OpenDialogReturn generic type (#919)
* type: add OpenDialogReturn generic type * chore: run pnpm format * type: export OpenDialogReturn type * chore: run pnpm format
This commit is contained in:
@@ -98,18 +98,14 @@ interface ConfirmDialogOptions {
|
|||||||
cancelLabel?: string;
|
cancelLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function open(
|
type OpenDialogReturn<T extends OpenDialogOptions> = T["directory"] extends true
|
||||||
options?: OpenDialogOptions & { multiple?: false; directory?: false },
|
? T["multiple"] extends true
|
||||||
): Promise<null | FileResponse>;
|
? string[] | null
|
||||||
async function open(
|
: string | null
|
||||||
options?: OpenDialogOptions & { multiple?: true; directory?: false },
|
: T["multiple"] extends true
|
||||||
): Promise<null | FileResponse[]>;
|
? FileResponse[] | null
|
||||||
async function open(
|
: FileResponse | null;
|
||||||
options?: OpenDialogOptions & { multiple?: false; directory?: true },
|
|
||||||
): Promise<null | string>;
|
|
||||||
async function open(
|
|
||||||
options?: OpenDialogOptions & { multiple?: true; directory?: true },
|
|
||||||
): Promise<null | string[]>;
|
|
||||||
/**
|
/**
|
||||||
* Open a file/directory selection dialog.
|
* Open a file/directory selection dialog.
|
||||||
*
|
*
|
||||||
@@ -162,9 +158,9 @@ async function open(
|
|||||||
*
|
*
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
async function open(
|
async function open<T extends OpenDialogOptions>(
|
||||||
options: OpenDialogOptions = {},
|
options: T = {} as T,
|
||||||
): Promise<null | string | string[] | FileResponse | FileResponse[]> {
|
): Promise<OpenDialogReturn<T>> {
|
||||||
if (typeof options === "object") {
|
if (typeof options === "object") {
|
||||||
Object.freeze(options);
|
Object.freeze(options);
|
||||||
}
|
}
|
||||||
@@ -298,6 +294,7 @@ export type {
|
|||||||
DialogFilter,
|
DialogFilter,
|
||||||
FileResponse,
|
FileResponse,
|
||||||
OpenDialogOptions,
|
OpenDialogOptions,
|
||||||
|
OpenDialogReturn,
|
||||||
SaveDialogOptions,
|
SaveDialogOptions,
|
||||||
MessageDialogOptions,
|
MessageDialogOptions,
|
||||||
ConfirmDialogOptions,
|
ConfirmDialogOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user