From 097eb47e1c00bdb13b781d0acd9d0b6d91590d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9C=D0=B0?= =?UTF-8?q?=D0=BB=D1=8E=D0=B3=D0=B8=D0=BD?= <d.malygin@iqdev.digital> Date: Thu, 9 Jan 2025 16:55:29 +0500 Subject: [PATCH] fix: ts errors --- src/App.vue | 2 -- src/common/helpers/common.ts | 3 ++- src/stories/components/Popup/Popup.vue | 6 +++--- src/stories/components/Table/Table.vue | 6 +++--- src/stories/components/Table/helpers.ts | 2 +- tsconfig.app.json | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/App.vue b/src/App.vue index 8d91ab7..00f92a0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,4 @@ <script setup lang="ts"> -import Drawer from '@stories/components/Drawer/Drawer.vue'; -import { ref } from 'vue'; import Age18Icon from '@stories/icons/Mono/Age18Icon.vue'; import AlarmIcon from '@stories/icons/Mono/AlarmIcon.vue'; import AirplaneIcon from '@stories/icons/Mono/AirplaneIcon.vue'; diff --git a/src/common/helpers/common.ts b/src/common/helpers/common.ts index 3da75fb..f3e9829 100644 --- a/src/common/helpers/common.ts +++ b/src/common/helpers/common.ts @@ -36,7 +36,7 @@ export const convertThemeToTextColor = (theme: TThemeColor, darkness: TDarkness /** * Convert color of type TThemeColor to shade of black or white */ -export const convertWhiteOrBlackToColor = (theme: 'white' | 'black', darkness: TDarkness) => { +export const convertWhiteOrBlackToColor = (theme: 'white' | 'black', darkness: TDarkness): string => { if (theme === 'white') { if (darkness === '500' || darkness === '400' || darkness === '600') return '#94a3b8'; if (darkness === '300' || darkness === '700') return '#cbd5e1'; @@ -47,6 +47,7 @@ export const convertWhiteOrBlackToColor = (theme: 'white' | 'black', darkness: T if (darkness === '300' || darkness === '700') return '#374151'; if (darkness === '200' || darkness === '800') return '#1f2937'; if (darkness === '100' || darkness === '900') return '#111827'; + return '#4b5563'; }; /** * Convert color of type TThemeColor to hex for border or scroll diff --git a/src/stories/components/Popup/Popup.vue b/src/stories/components/Popup/Popup.vue index dc2b20f..d1eaa98 100644 --- a/src/stories/components/Popup/Popup.vue +++ b/src/stories/components/Popup/Popup.vue @@ -39,7 +39,7 @@ watch( left.value = props.left ?? clientRect.left; } - container.value.addEventListener('pointerdown', (event: Event) => { + container.value.addEventListener('pointerdown', (event: MouseEvent) => { const e = event as PointerEvent; if (e.button === 2 || (props.buttonMenu && e.button === 0)) { isOnContainerClick.value = true; @@ -51,12 +51,12 @@ watch( e.stopPropagation(); } }); - container.value.addEventListener('contextmenu', (e) => { + container.value.addEventListener('contextmenu', (e: MouseEvent) => { if (isOnContainerClick.value) e.preventDefault(); }); } - document.addEventListener('pointerdown', (e) => { + document.addEventListener('pointerdown', (e: MouseEvent) => { if (!props.buttonMenu && e.button === 0 && !(window as CustomWindow).blockPopupActions) active.value = false; }); }, diff --git a/src/stories/components/Table/Table.vue b/src/stories/components/Table/Table.vue index 5a254bc..d536bb9 100644 --- a/src/stories/components/Table/Table.vue +++ b/src/stories/components/Table/Table.vue @@ -23,7 +23,7 @@ const isRegisterSensitive = ref<boolean>(false); watch(props.columns, () => (columns.value = props.columns)); -const initGap = computed(() => calcGap(props.gap, props.fontSize)); +const initGap = computed(() => calcGap(props.gap ?? '0px', props.fontSize)); const additionalHeightFromSize = computed(() => calcAdditionalHeight(props.size, props.fontSize)); const themeColor = computed(() => convertThemeToColor(props.theme, props.darknessTheme)); const color = computed(() => @@ -31,7 +31,7 @@ const color = computed(() => ? convertThemeToColor(props.textColor, props.darknessTextColor) : convertThemeToTextColor(props.theme, props.darknessTheme), ); -const secondaryColor = computed(() => convertThemeToSecondaryColor(props.theme, props.darknessTheme)); +const secondaryColor = computed<string>(() => convertThemeToSecondaryColor(props.theme, props.darknessTheme)); const darkCellColor = computed(() => convertThemeToSecondaryColor(props.theme, String(+props.darknessTheme + 300))); // ['', 'up', 'none', '', 'none', ...] const sortState = computed<string[]>(() => { @@ -47,7 +47,7 @@ const rows = computed<ITableItem[][]>(() => sortStateActive.value, props.multipleSort, columnToFilter.value, - props.columns[columnToFilter.value ?? 0].type, + props.columns[columnToFilter.value ?? 0].type ?? 'text', filterValue.value, isRegisterSensitive.value, ), diff --git a/src/stories/components/Table/helpers.ts b/src/stories/components/Table/helpers.ts index 6ebe279..fbb49f2 100644 --- a/src/stories/components/Table/helpers.ts +++ b/src/stories/components/Table/helpers.ts @@ -64,7 +64,7 @@ export const calcGap = (gap: string, fontSize: string) => export const calcAdditionalHeight = (size: TSize, fontSize: string) => { if (size === 'normal') return '0px'; - const isTwoLetters = isFinite(+fontSize.at(-3)!); + const isTwoLetters = isFinite(+fontSize[fontSize.length - 3]!); const value = isTwoLetters ? fontSize.slice(0, -2) : fontSize.slice(0, -3); const unit = isTwoLetters ? fontSize.slice(-2) : fontSize.slice(-3); diff --git a/tsconfig.app.json b/tsconfig.app.json index b5c26be..0cd87b1 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -1,6 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.dom.json", - "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "App.vue"], + "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/**/*.ts","App.vue"], "exclude": ["src/**/__tests__/*"], "compilerOptions": { "composite": true, -- GitLab