Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(frontend): asとanyをすぐなおせる範囲で除去 #14848

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkAntennaEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async function deleteAntenna() {
function addUser() {
os.selectUser({ includeSelf: true }).then(user => {
users.value = users.value.trim();
users.value += '\n@' + Misskey.acct.toString(user as any);
users.value += '\n@' + Misskey.acct.toString(user);
users.value = users.value.trim();
});
}
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/components/MkChannelPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { computed, ref, watch } from 'vue';
import * as Misskey from 'misskey-js';
import { i18n } from '@/i18n.js';
import { miLocalStorage } from '@/local-storage.js';

const props = defineProps<{
channel: Record<string, any>;
channel: Misskey.entities.Channel;
}>();

const getLastReadedAt = (): number | null => {
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
</MkSelect>
<div v-if="(showOkButton || showCancelButton) && !actions" :class="$style.buttons">
<MkButton v-if="showOkButton" data-cy-modal-dialog-ok inline primary rounded :autofocus="!input && !select" :disabled="okButtonDisabledReason" @click="ok">{{ okText ?? ((showCancelButton || input || select) ? i18n.ts.ok : i18n.ts.gotIt) }}</MkButton>
<MkButton v-if="showOkButton" data-cy-modal-dialog-ok inline primary rounded :autofocus="!input && !select" :disabled="okButtonDisabledReason != null" @click="ok">{{ okText ?? ((showCancelButton || input || select) ? i18n.ts.ok : i18n.ts.gotIt) }}</MkButton>
<MkButton v-if="showCancelButton || input || select" data-cy-modal-dialog-cancel inline rounded @click="cancel">{{ cancelText ?? i18n.ts.cancel }}</MkButton>
</div>
<div v-if="actions" :class="$style.buttons">
Expand Down Expand Up @@ -98,7 +98,7 @@ const props = withDefaults(defineProps<{
text: string;
primary?: boolean,
danger?: boolean,
callback: (...args: any[]) => void;
callback: (...args: unknown[]) => void;
}[];
showOkButton?: boolean;
showCancelButton?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/components/MkDrive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const ilFilesObserver = new IntersectionObserver(
(entries) => entries.some((entry) => entry.isIntersecting) && !fetching.value && moreFiles.value && fetchMoreFiles(),
);

const sortModeSelect = ref('+createdAt');
const sortModeSelect = ref<NonNullable<Misskey.entities.DriveFilesRequest['sort']>>('+createdAt');

watch(folder, () => emit('cd', folder.value));
watch(sortModeSelect, () => {
Expand Down Expand Up @@ -198,7 +198,7 @@ function onStreamDriveFolderDeleted(folderId: string) {
removeFolder(folderId);
}

function onDragover(ev: DragEvent): any {
function onDragover(ev: DragEvent) {
if (!ev.dataTransfer) return;

// ドラッグ元が自分自身の所有するアイテムだったら
Expand Down Expand Up @@ -243,7 +243,7 @@ function onDragleave() {
draghover.value = false;
}

function onDrop(ev: DragEvent): any {
function onDrop(ev: DragEvent) {
draghover.value = false;

if (!ev.dataTransfer) return;
Expand Down Expand Up @@ -332,7 +332,7 @@ function createFolder() {
title: i18n.ts.createFolder,
placeholder: i18n.ts.folderName,
}).then(({ canceled, result: name }) => {
if (canceled) return;
if (canceled || name == null) return;
misskeyApi('drive/folders/create', {
name: name,
parentId: folder.value ? folder.value.id : undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkEmojiPicker.section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function computeButtonTitle(ev: MouseEvent): void {
elm.title = getEmojiName(emoji);
}

function nestedChosen(emoji: any, ev: MouseEvent) {
function nestedChosen(emoji: string, ev: MouseEvent) {
emit('chosen', emoji, ev);
}
</script>
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkEmojiPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function computeButtonTitle(ev: MouseEvent): void {
elm.title = getEmojiName(emoji);
}

function chosen(emoji: any, ev?: MouseEvent) {
function chosen(emoji: string | Misskey.entities.EmojiSimple | UnicodeEmojiDef, ev?: MouseEvent) {
const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined;
if (el) {
const rect = el.getBoundingClientRect();
Expand All @@ -426,7 +426,7 @@ function chosen(emoji: any, ev?: MouseEvent) {
// 最近使った絵文字更新
if (!pinned.value?.includes(key)) {
let recents = defaultStore.state.recentlyUsedEmojis;
recents = recents.filter((emoji: any) => emoji !== key);
recents = recents.filter((emoji) => emoji !== key);
recents.unshift(key);
defaultStore.set('recentlyUsedEmojis', recents.splice(0, 32));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkExtensionInstaller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export type Extension = {
author: string;
description?: string;
permissions?: string[];
config?: Record<string, any>;
config?: Record<string, unknown>;
};
} | {
type: 'theme';
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/components/MkInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import { onMounted, onUnmounted, nextTick, ref, shallowRef, watch, computed, toRefs } from 'vue';
import { onMounted, onUnmounted, nextTick, ref, shallowRef, watch, computed, toRefs, InputHTMLAttributes } from 'vue';
import { debounce } from 'throttle-debounce';
import MkButton from '@/components/MkButton.vue';
import { useInterval } from '@@/js/use-interval.js';
Expand All @@ -53,7 +53,7 @@ import { Autocomplete, SuggestionType } from '@/scripts/autocomplete.js';

const props = defineProps<{
modelValue: string | number | null;
type?: 'text' | 'number' | 'password' | 'email' | 'url' | 'date' | 'time' | 'search' | 'datetime-local';
type?: InputHTMLAttributes['type'];
required?: boolean;
readonly?: boolean;
disabled?: boolean;
Expand All @@ -64,8 +64,8 @@ const props = defineProps<{
mfmAutocomplete?: boolean | SuggestionType[],
autocapitalize?: string;
spellcheck?: boolean;
inputmode?: 'none' | 'text' | 'search' | 'email' | 'url' | 'numeric' | 'tel' | 'decimal';
step?: any;
inputmode?: InputHTMLAttributes['inputmode'];
step?: InputHTMLAttributes['step'];
datalist?: string[];
min?: number;
max?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const props = withDefaults(defineProps<{

const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();

const typesMap: TypesMap = notificationTypes.reduce((p, t) => ({ ...p, [t]: ref<boolean>(!props.excludeTypes.includes(t)) }), {} as any);
const typesMap = notificationTypes.reduce((p, t) => ({ ...p, [t]: ref<boolean>(!props.excludeTypes.includes(t)) }), {} as TypesMap);

function ok() {
emit('done', {
Expand Down
10 changes: 5 additions & 5 deletions packages/frontend/src/components/MkObjectView.value.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import number from '@/filters/number.js';
import XValue from '@/components/MkObjectView.value.vue';

const props = defineProps<{
value: any;
value: unknown;
}>();

const collapsed = reactive({});
Expand All @@ -50,19 +50,19 @@ if (isObject(props.value)) {
}
}

function isObject(v): boolean {
function isObject(v: unknown): v is Record<PropertyKey, unknown> {
return typeof v === 'object' && !Array.isArray(v) && v !== null;
}

function isArray(v): boolean {
function isArray(v: unknown): v is unknown[] {
return Array.isArray(v);
}

function isEmpty(v): boolean {
function isEmpty(v: unknown): v is Record<PropertyKey, never> | never[] {
return (isArray(v) && v.length === 0) || (isObject(v) && Object.keys(v).length === 0);
}

function collapsable(v): boolean {
function collapsable(v: unknown): boolean {
return (isObject(v) || isArray(v)) && !isEmpty(v);
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkPageWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const windowRouter = routerFactory(props.initialPath);
const contents = shallowRef<HTMLElement | null>(null);
const pageMetadata = ref<null | PageMetadata>(null);
const windowEl = shallowRef<InstanceType<typeof MkWindow>>();
const history = ref<{ path: string; key: any; }[]>([{
const history = ref<{ path: string; key: string; }[]>([{
path: windowRouter.getCurrentPath(),
key: windowRouter.getCurrentKey(),
}]);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkPopupMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defineProps<{
items: MenuItem[];
align?: 'center' | string;
width?: number;
src?: any;
src?: HTMLElement | null;
returnFocusTo?: HTMLElement | null;
}>();

Expand Down
20 changes: 4 additions & 16 deletions packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,13 @@ import { miLocalStorage } from '@/local-storage.js';
import { claimAchievement } from '@/scripts/achievements.js';
import { emojiPicker } from '@/scripts/emoji-picker.js';
import { mfmFunctionPicker } from '@/scripts/mfm-function-picker.js';
import type { PostFormProps } from '@/types/post-form.js';

const $i = signinRequired();

const modal = inject('modal');

const props = withDefaults(defineProps<{
reply?: Misskey.entities.Note;
renote?: Misskey.entities.Note;
channel?: Misskey.entities.Channel; // TODO
mention?: Misskey.entities.User;
specified?: Misskey.entities.UserDetailed;
initialText?: string;
initialCw?: string;
initialVisibility?: (typeof Misskey.noteVisibilities)[number];
initialFiles?: Misskey.entities.DriveFile[];
initialLocalOnly?: boolean;
initialVisibleUsers?: Misskey.entities.UserDetailed[];
initialNote?: Misskey.entities.Note;
instant?: boolean;
const props = withDefaults(defineProps<PostFormProps & {
fixed?: boolean;
autofocus?: boolean;
freezeAfterPosted?: boolean;
Expand Down Expand Up @@ -955,8 +943,8 @@ function showActions(ev: MouseEvent) {
action.handler({
text: text.value,
cw: cw.value,
}, (key, value: any) => {
if (typeof key !== 'string') return;
}, (key, value) => {
if (typeof key !== 'string' || typeof value !== 'string') return;
if (key === 'text') { text.value = value; }
if (key === 'cw') { useCw.value = value !== null; cw.value = value; }
});
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/components/MkPostFormAttaches.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div v-show="props.modelValue.length != 0" :class="$style.root">
<Sortable :modelValue="props.modelValue" :class="$style.files" itemKey="id" :animation="150" :delay="100" :delayOnTouchOnly="true" @update:modelValue="v => emit('update:modelValue', v)">
<template #item="{element}">
<template #item="{ element }">
<div
:class="$style.file"
role="button"
Expand Down Expand Up @@ -38,14 +38,14 @@ import type { MenuItem } from '@/types/menu.js';
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));

const props = defineProps<{
modelValue: any[];
modelValue: Misskey.entities.DriveFile[];
detachMediaFn?: (id: string) => void;
}>();

const mock = inject<boolean>('mock', false);

const emit = defineEmits<{
(ev: 'update:modelValue', value: any[]): void;
(ev: 'update:modelValue', value: Misskey.entities.DriveFile[]): void;
(ev: 'detach', id: string): void;
(ev: 'changeSensitive', file: Misskey.entities.DriveFile, isSensitive: boolean): void;
(ev: 'changeName', file: Misskey.entities.DriveFile, newName: string): void;
Expand Down Expand Up @@ -113,7 +113,7 @@ async function rename(file) {
});
}

async function describe(file) {
async function describe(file: Misskey.entities.DriveFile) {
if (mock) return;

const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), {
Expand Down
16 changes: 2 additions & 14 deletions packages/frontend/src/components/MkPostFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,11 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { shallowRef } from 'vue';
import * as Misskey from 'misskey-js';
import MkModal from '@/components/MkModal.vue';
import MkPostForm from '@/components/MkPostForm.vue';
import type { PostFormProps } from '@/types/post-form.js';

const props = withDefaults(defineProps<{
reply?: Misskey.entities.Note;
renote?: Misskey.entities.Note;
channel?: any; // TODO
mention?: Misskey.entities.User;
specified?: Misskey.entities.UserDetailed;
initialText?: string;
initialCw?: string;
initialVisibility?: (typeof Misskey.noteVisibilities)[number];
initialFiles?: Misskey.entities.DriveFile[];
initialLocalOnly?: boolean;
initialVisibleUsers?: Misskey.entities.UserDetailed[];
initialNote?: Misskey.entities.Note;
const props = withDefaults(defineProps<PostFormProps & {
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/components/MkRadio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</template>

<script lang="ts" setup>
<script lang="ts" setup generic="T extends unknown">
import { computed } from 'vue';

const props = defineProps<{
modelValue: any;
value: any;
modelValue: T;
value: T;
disabled?: boolean;
}>();

const emit = defineEmits<{
(ev: 'update:modelValue', value: any): void;
(ev: 'update:modelValue', value: T): void;
}>();

const checked = computed(() => props.modelValue === props.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { } from 'vue';
import * as Misskey from 'misskey-js';
import { getEmojiName } from '@@/js/emojilist.js';
import MkTooltip from './MkTooltip.vue';
import MkReactionIcon from '@/components/MkReactionIcon.vue';

defineProps<{
showing: boolean;
reaction: string;
users: any[]; // TODO
users: Misskey.entities.UserLite[];
count: number;
targetElement: HTMLElement;
}>();
Expand Down
33 changes: 30 additions & 3 deletions packages/frontend/src/components/MkSuperMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,38 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</template>

<script lang="ts" setup>
import { } from 'vue';
<script lang="ts">
export type SuperMenuDef = {
title?: string;
items: ({
type: 'a';
href: string;
target?: string;
icon?: string;
text: string;
danger?: boolean;
active?: boolean;
} | {
type: 'button';
icon?: string;
text: string;
danger?: boolean;
active?: boolean;
action: (ev: MouseEvent) => void;
} | {
type: 'link';
to: string;
icon?: string;
text: string;
danger?: boolean;
active?: boolean;
})[];
};
</script>

<script lang="ts" setup>
defineProps<{
def: any[];
def: SuperMenuDef[];
grid?: boolean;
}>();
</script>
Expand Down
Loading
Loading