perf: enable strict ts type checking (#4045)

This commit is contained in:
Vben
2024-08-05 21:12:22 +08:00
committed by GitHub
parent e5ec8e6b51
commit 4f5783d00b
41 changed files with 124 additions and 76 deletions

View File

@@ -71,7 +71,7 @@ async function generateRoutes(
const firstChild = route.children[0];
// 如果子路由不是以/开头,则直接返回,这种情况需要计算全部父级的path才能得出正确的path这里不做处理
if (!firstChild.path || !firstChild.path.startsWith('/')) {
if (!firstChild?.path || !firstChild.path.startsWith('/')) {
return route;
}

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import type { AuthenticationProps, LoginAndRegisterParams } from './typings';
import { useForwardPropsEmits } from '@vben/hooks';
import {
Dialog,
@@ -10,7 +12,6 @@ import {
} from '@vben-core/shadcn-ui';
import AuthenticationLogin from './login.vue';
import { AuthenticationProps, LoginAndRegisterParams } from './typings';
interface Props extends AuthenticationProps {
avatar?: string;

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import type { AuthenticationProps, LoginEmits } from './typings';
import { computed, reactive } from 'vue';
import { useRouter } from 'vue-router';
@@ -12,7 +14,6 @@ import {
import Title from './auth-title.vue';
import ThirdPartyLogin from './third-party-login.vue';
import { AuthenticationProps, LoginEmits } from './typings';
interface Props extends AuthenticationProps {}

View File

@@ -18,7 +18,7 @@ const props = withDefaults(defineProps<Props>(), {
});
const defaultValue = computed(() => {
return props.tabs?.[0].value;
return props.tabs?.[0]?.value;
});
</script>

View File

@@ -1,4 +1,6 @@
<script lang="ts" setup>
import type { MenuRecordRaw } from '@vben/types';
import { computed, watch } from 'vue';
import { useWatermark } from '@vben/hooks';
@@ -9,7 +11,6 @@ import {
usePreferences,
} from '@vben/preferences';
import { useLockStore, useUserStore } from '@vben/stores';
import { MenuRecordRaw } from '@vben/types';
import { mapTree } from '@vben/utils';
import { VbenAdminLayout } from '@vben-core/layout-ui';
import { Toaster, VbenBackTop, VbenLogo } from '@vben-core/shadcn-ui';

View File

@@ -1,9 +1,10 @@
<script lang="ts" setup>
import type { MenuRecordRaw } from '@vben/types';
import type { MenuProps } from '@vben-core/menu-ui';
import { useRoute } from 'vue-router';
import { Menu, MenuProps } from '@vben-core/menu-ui';
import { Menu } from '@vben-core/menu-ui';
import { useNavigation } from './use-navigation';

View File

@@ -1,7 +1,8 @@
<script lang="ts" setup>
import type { MenuRecordRaw } from '@vben/types';
import type { MenuProps } from '@vben-core/menu-ui';
import { Menu, MenuProps } from '@vben-core/menu-ui';
import { Menu } from '@vben-core/menu-ui';
interface Props extends MenuProps {
menus?: MenuRecordRaw[];

View File

@@ -49,7 +49,7 @@ function handleClose() {
const keys = useMagicKeys();
const cmd = isWindowsOs() ? keys['ctrl+k'] : keys['cmd+k'];
whenever(cmd, () => {
whenever(cmd!, () => {
if (props.enableShortcutKey) {
open.value = true;
}

View File

@@ -95,10 +95,12 @@ async function handleEnter() {
return;
}
const to = result[index];
searchHistory.value.push(to);
handleClose();
await nextTick();
router.push(to.path);
if (to) {
searchHistory.value.push(to);
handleClose();
await nextTick();
router.push(to.path);
}
}
// Arrow key up

View File

@@ -1,8 +1,9 @@
<script setup lang="ts">
import type { SelectOption } from '@vben/types';
import { computed } from 'vue';
import { $t } from '@vben/locales';
import { SelectOption } from '@vben/types';
import SelectItem from '../select-item.vue';
import SwitchItem from '../switch-item.vue';

View File

@@ -126,19 +126,19 @@ function handleSubmitLogout() {
if (enableShortcutKey.value) {
const keys = useMagicKeys();
whenever(keys['Alt+KeyQ'], () => {
whenever(keys['Alt+KeyQ']!, () => {
if (enableLogoutShortcutKey.value) {
handleLogout();
}
});
whenever(keys['Alt+Comma'], () => {
whenever(keys['Alt+Comma']!, () => {
if (enablePreferencesShortcutKey.value) {
handleOpenPreference();
}
});
whenever(keys['Alt+KeyL'], () => {
whenever(keys['Alt+KeyL']!, () => {
if (enableLockScreenShortcutKey.value) {
handleOpenLock();
}

View File

@@ -1,7 +1,7 @@
import {
import type {
AxiosInstance,
AxiosResponse,
type InternalAxiosRequestConfig,
InternalAxiosRequestConfig,
} from 'axios';
const errorHandler = (res: Error) => Promise.reject(res);