summaryrefslogtreecommitdiff
path: root/packages/frontend/src/os.ts
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2025-09-13 21:00:33 +0900
committerGitHub <noreply@github.com>2025-09-13 21:00:33 +0900
commitd4654dd7bd5bf1c7faa74ed89f592448c0076be8 (patch)
treeb4f51e86f174717fef469fbedca48faa2a55e841 /packages/frontend/src/os.ts
parentfix(deps): update dependency vite [security] (#16535) (diff)
downloadmisskey-d4654dd7bd5bf1c7faa74ed89f592448c0076be8.tar.gz
misskey-d4654dd7bd5bf1c7faa74ed89f592448c0076be8.tar.bz2
misskey-d4654dd7bd5bf1c7faa74ed89f592448c0076be8.zip
refactor(frontend): os.select, MkSelectのitem指定をオブジェクトによる定義に統一し、型を狭める (#16475)
* refactor(frontend): MkSelectのitem指定をオブジェクトによる定義に統一 * fix * spdx * fix * fix os.select * fix lint * add comment * fix * fix: os.select対応漏れを修正 * fix * fix * fix: MkSelectのmodelに対する型チェックを厳格化 * fix * fix * fix * Update packages/frontend/src/components/MkEmbedCodeGenDialog.vue Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> * fix * fix types * fix * fix * Update packages/frontend/src/pages/admin/roles.editor.vue Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> * fix: MkSelectに直接配列を指定している場合に正常に型が解決されるように --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/os.ts')
-rw-r--r--packages/frontend/src/os.ts44
1 files changed, 5 insertions, 39 deletions
diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts
index 504ae19f1d..6c5f04c6b5 100644
--- a/packages/frontend/src/os.ts
+++ b/packages/frontend/src/os.ts
@@ -14,6 +14,7 @@ import type { Form, GetFormResultType } from '@/utility/form.js';
import type { MenuItem } from '@/types/menu.js';
import type { PostFormProps } from '@/types/post-form.js';
import type { UploaderFeatures } from '@/composables/use-uploader.js';
+import type { MkSelectItem, OptionValue } from '@/components/MkSelect.vue';
import type MkRoleSelectDialog_TypeReferenceOnly from '@/components/MkRoleSelectDialog.vue';
import type MkEmojiPickerDialog_TypeReferenceOnly from '@/components/MkEmojiPickerDialog.vue';
import { misskeyApi } from '@/utility/misskey-api.js';
@@ -502,50 +503,15 @@ export function authenticateDialog(): Promise<{
});
}
-type SelectItem<C> = {
- value: C;
- text: string;
-};
-
-// default が指定されていたら result は null になり得ないことを保証する overload function
-export function select<C = unknown>(props: {
+export function select<C extends OptionValue, D extends C | null = null>(props: {
title?: string;
text?: string;
- default: string;
- items: (SelectItem<C> | {
- sectionTitle: string;
- items: SelectItem<C>[];
- } | undefined)[];
-}): Promise<{
- canceled: true; result: undefined;
-} | {
- canceled: false; result: C;
-}>;
-export function select<C = unknown>(props: {
- title?: string;
- text?: string;
- default?: string | null;
- items: (SelectItem<C> | {
- sectionTitle: string;
- items: SelectItem<C>[];
- } | undefined)[];
-}): Promise<{
- canceled: true; result: undefined;
-} | {
- canceled: false; result: C | null;
-}>;
-export function select<C = unknown>(props: {
- title?: string;
- text?: string;
- default?: string | null;
- items: (SelectItem<C> | {
- sectionTitle: string;
- items: SelectItem<C>[];
- } | undefined)[];
+ default?: D;
+ items: (MkSelectItem<C> | undefined)[];
}): Promise<{
canceled: true; result: undefined;
} | {
- canceled: false; result: C | null;
+ canceled: false; result: Exclude<D, undefined> extends null ? C | null : C;
}> {
return new Promise(resolve => {
const { dispose } = popup(MkDialog, {