Skip to content

Commit 0235388

Browse files
committed
build(frontend): migrate js to ts
1 parent e0ff940 commit 0235388

24 files changed

+285
-197
lines changed

frontend/components.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-disable */
2+
/* prettier-ignore */
3+
// @ts-nocheck
4+
// Generated by unplugin-vue-components
5+
// Read more: https://github.com/vuejs/core/pull/3399
6+
export {}
7+
8+
declare module 'vue' {
9+
export interface GlobalComponents {
10+
ASpin: typeof import('ant-design-vue/es')['Spin']
11+
Button: typeof import('./src/components/ui/Button.vue')['default']
12+
Footer: typeof import('./src/components/Footer.vue')['default']
13+
Highlights: typeof import('./src/components/Highlights.vue')['default']
14+
IconBillCheck: typeof import('./src/components/icons/IconBillCheck.vue')['default']
15+
IconGithub: typeof import('./src/components/icons/IconGithub.vue')['default']
16+
IconHeart: typeof import('./src/components/icons/IconHeart.vue')['default']
17+
IconMagicStick: typeof import('./src/components/icons/IconMagicStick.vue')['default']
18+
IconPalette: typeof import('./src/components/icons/IconPalette.vue')['default']
19+
IconTelegram: typeof import('./src/components/icons/IconTelegram.vue')['default']
20+
IconTwitch: typeof import('./src/components/icons/IconTwitch.vue')['default']
21+
IconValory: typeof import('./src/components/icons/IconValory.vue')['default']
22+
IconValoryBG: typeof import('./src/components/icons/IconValoryBG.vue')['default']
23+
Input: typeof import('./src/components/ui/Input.vue')['default']
24+
LanguageSwitcher: typeof import('./src/components/ui/LanguageSwitcher.vue')['default']
25+
Overlay: typeof import('./src/components/Overlay.vue')['default']
26+
RouterLink: typeof import('vue-router')['RouterLink']
27+
RouterView: typeof import('vue-router')['RouterView']
28+
Switch: typeof import('./src/components/ui/Switch.vue')['default']
29+
}
30+
}

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
Enable JavaScript to enjoy all the features of this app.
4141
</noscript>
4242
<div id="app"></div>
43-
<script type="module" src="./src/main.js"></script>
43+
<script type="module" src="./src/main.ts"></script>
4444
</body>
4545
</html>

frontend/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"postcss-uncss": "^0.17.0",
3232
"query-string": "^8.1.0",
3333
"set-interval-async": "^3.0.3",
34+
"typescript": "^5.7.2",
3435
"uncss": "^0.17.3",
3536
"v-click-outside": "^3.2.0",
3637
"vue-i18n": "9",
@@ -41,8 +42,9 @@
4142
"@plugin-web-update-notification/vite": "^1.6.6",
4243
"@rushstack/eslint-patch": "^1.3.3",
4344
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
44-
"@vitejs/plugin-vue": "^4.4.0",
45+
"@vitejs/plugin-vue": "^4.6.2",
4546
"@vue/eslint-config-prettier": "^8.0.0",
47+
"@vue/runtime-dom": "^3.5.13",
4648
"autoprefixer": "^10.4.16",
4749
"eslint": "^9.15.0",
4850
"eslint-config-prettier": "^9.0.0",
@@ -55,6 +57,7 @@
5557
"unplugin-vue-components": "^0.25.2",
5658
"vite": "^4.4.11",
5759
"vue": "^3.3.4",
58-
"vue-router": "^4.2.5"
60+
"vue-router": "^4.2.5",
61+
"vue-tsc": "^2.1.10"
5962
}
6063
}

frontend/src/App.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
<script setup>
2-
import Highlights from '@/components/Highlights.vue'
3-
import { LoadingOutlined } from '@ant-design/icons-vue'
4-
import { ref } from 'vue'
5-
import { h } from 'vue'
6-
import { useRouter } from 'vue-router'
1+
<script setup lang="ts">
2+
import Highlights from '@/components/Highlights.vue';
3+
import { LoadingOutlined } from '@ant-design/icons-vue';
4+
import { ref, h } from 'vue';
5+
import { useRouter } from 'vue-router';
76
8-
const isRouterReady = ref(false)
9-
const router = useRouter()
7+
const isRouterReady = ref<boolean>(false);
108
11-
router.isReady().finally(() => (isRouterReady.value = true))
9+
const router = useRouter();
10+
11+
router.isReady().finally(() => {
12+
isRouterReady.value = true;
13+
});
1214
1315
const indicator = h(LoadingOutlined, {
1416
style: {
15-
fontSize: '36px'
17+
fontSize: '36px',
1618
},
17-
spin: true
18-
})
19+
spin: true,
20+
});
1921
</script>
2022

2123
<template>

frontend/src/components/Footer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup>
1+
<script setup lang="ts">
22
import IconGithub from '@/components/icons/IconGithub.vue'
33
import IconHeart from '@/components/icons/IconHeart.vue'
44
import IconTelegram from '@/components/icons/IconTelegram.vue'

frontend/src/components/Highlights.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup></script>
1+
<script setup lang="ts"></script>
22

33
<template>
44
<div class="blicks">

frontend/src/components/Overlay.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup>
1+
<script setup lang="ts">
22
import IconValory from '@/components/icons/IconValory.vue'
33
</script>
44

frontend/src/components/ui/Button.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
<script setup>
2-
defineProps({
3-
variant: {
4-
type: String
5-
},
6-
disabled: {
7-
type: Boolean,
8-
default: false
9-
},
10-
type: {
11-
type: String
12-
}
13-
})
1+
<script setup lang="ts">
2+
interface ButtonProps {
3+
variant?: string;
4+
disabled?: boolean;
5+
type?: string;
6+
}
7+
8+
defineProps<ButtonProps>();
149
</script>
1510

1611
<template>

frontend/src/components/ui/Input.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup>
1+
<script setup lang="ts">
22
defineProps(['modelValue', 'placeholder'])
33
</script>
44

frontend/src/components/ui/LanguageSwitcher.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
<script setup>
2-
import { useLocalStorage } from '@vueuse/core'
3-
import { NConfigProvider, NDropdown, darkTheme } from 'naive-ui'
4-
import { useI18n } from 'vue-i18n'
1+
<script setup lang="ts">
2+
import { useLocalStorage } from '@vueuse/core';
3+
import { NConfigProvider, NDropdown, NButton, darkTheme } from 'naive-ui';
4+
import { useI18n } from 'vue-i18n';
55
6-
const { locale, availableLocales } = useI18n()
7-
const localStorageLocale = useLocalStorage('valoryLocale', 'en')
6+
const { locale, availableLocales } = useI18n<{ locale: string; availableLocales: string[] }>();
7+
const localStorageLocale = useLocalStorage<string>('valoryLocale', 'en');
8+
9+
const handleSelectLocale = (selectedLocale: string) => {
10+
locale.value = selectedLocale;
11+
localStorageLocale.value = selectedLocale;
12+
};
813
</script>
914

1015
<template>
@@ -19,12 +24,7 @@ const localStorageLocale = useLocalStorage('valoryLocale', 'en')
1924
}))
2025
"
2126
size="medium"
22-
@select="
23-
(l) => {
24-
locale = l
25-
localStorageLocale = l
26-
}
27-
"
27+
@select="handleSelectLocale"
2828
>
2929
<n-button circle quaternary style="padding: 5px; font-size: 25px">
3030
<Icon :icon="`flag:${$t('flag')}-4x3`" width="18" height="18" />

0 commit comments

Comments
 (0)