From e8a256e66700c7b859bb4ab05e65a80e214756d7 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Sun, 12 Nov 2023 13:21:23 +0900 Subject: [PATCH] (refactor) better types --- nuxt.config.ts | 8 ++++++-- types/misc.d.ts | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index eaca3797..85cf391b 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -9,7 +9,7 @@ import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables'; const baseUrl = 'https://misskey-hub.net'; // 言語定義 -export const locales = [ +export const localesConst = [ { code: 'ja', iso: 'ja-JP', name: '日本語' }, { code: 'en', iso: 'en-US', name: 'English' }, { code: 'id', iso: 'id-ID', name: 'Bahasa Indonesia' }, @@ -19,7 +19,11 @@ export const locales = [ { code: 'fr', iso: 'fr-FR', name: 'Français' }, { code: 'cn', iso: 'zh-CN', name: '简体中文' }, { code: 'tw', iso: 'zh-TW', name: '繁体中文' }, -] as LocaleObject[]; +] as const; + +export type LocaleCodes = typeof localesConst[number]['code']; + +export const locales = localesConst as unknown as LocaleObject[]; export default defineNuxtConfig({ runtimeConfig: { diff --git a/types/misc.d.ts b/types/misc.d.ts index 8b201556..fef9b416 100644 --- a/types/misc.d.ts +++ b/types/misc.d.ts @@ -1,3 +1,5 @@ +import type { LocaleCodes } from './../nuxt.config'; + declare module '*.svg' { import { FunctionalComponent, SVGAttributes } from 'vue' const src: FunctionalComponent @@ -5,7 +7,8 @@ declare module '*.svg' { } declare module 'nuxt/schema' { - interface AppConfig { + + interface CustomAppConfig { /** お知らせ */ notice?: { @@ -27,7 +30,7 @@ declare module 'nuxt/schema' { * ``` * **/ - title: { ja: string; } & Record; + title: { ja: string; } & Partial>; /** * リンク先