From 2191c40f1c6e1f4ad32969220275cb76bd8bce79 Mon Sep 17 00:00:00 2001 From: Dmitry Balashov Date: Mon, 13 Mar 2023 13:22:25 +0700 Subject: [PATCH] [refactor]: enable `noImplicitReturns` New issue: https://github.com/soramitsu/soramitsu-js-ui-library/issues/517 I refactored some stuff in DatePicker with no deep understanding of logic, but preserving effects (and deleting unreachable ones) --- packages/ui/rollup.dts.config.ts | 2 ++ packages/ui/src/components/DatePicker/SDatePicker.vue | 8 +++----- .../src/components/DatePicker/SDatePickerPanelCustom.vue | 4 ++++ packages/ui/src/components/Table/use-table-heights.ts | 4 +++- tsconfig.json | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/ui/rollup.dts.config.ts b/packages/ui/rollup.dts.config.ts index 43f17c11..3c4101d9 100644 --- a/packages/ui/rollup.dts.config.ts +++ b/packages/ui/rollup.dts.config.ts @@ -11,9 +11,11 @@ const shimCssPlugin = (): Plugin => { name: 'soramitsu-ui:shim-css', resolveId(id) { if (/\.(css|scss|sass)$/.test(id)) return id + CSS_SUFFIX + return }, load(id) { if (id.endsWith(CSS_SUFFIX)) return `declare const css: string\n export default css` + return }, } } diff --git a/packages/ui/src/components/DatePicker/SDatePicker.vue b/packages/ui/src/components/DatePicker/SDatePicker.vue index 24cc035d..c1c5992e 100644 --- a/packages/ui/src/components/DatePicker/SDatePicker.vue +++ b/packages/ui/src/components/DatePicker/SDatePicker.vue @@ -133,9 +133,8 @@ const updateShowedMonths = () => { case 'range': date = rangeState[dateForTime.value as keyof RangeState] as Date | null break - default: } - if (!date) return `00:00` + if (!date) return updateShowedState(date.getMonth(), date.getFullYear()) } @@ -196,7 +195,7 @@ const changeView = (viewName: string) => { currentView.value = viewName } -const headTitle = computed(() => { +const headTitle = computed(() => { if (menuState.value && menuState.value !== 'Custom') { return menuState.value } @@ -209,13 +208,12 @@ const headTitle = computed(() => { const modelValue = props.modelValue as Date[] return modelValue.map((item) => formatDate(item)).join(' - ') } - case 'pick': { const modelValue = props.modelValue as Date[] return modelValue.map((item) => formatDate(item)).join(', ') } default: - break + return '' } } catch { return '' diff --git a/packages/ui/src/components/DatePicker/SDatePickerPanelCustom.vue b/packages/ui/src/components/DatePicker/SDatePickerPanelCustom.vue index 361b2bf6..b0a124c0 100644 --- a/packages/ui/src/components/DatePicker/SDatePickerPanelCustom.vue +++ b/packages/ui/src/components/DatePicker/SDatePickerPanelCustom.vue @@ -92,6 +92,8 @@ function dateMask(date: string) { if (date.match(/^\d{2}\/\d{2}$/) !== null) { return date + '/' } + + return undefined } function dateTimeMask(date: string) { @@ -112,6 +114,8 @@ function dateTimeMask(date: string) { if (date.match(/^\d{2}\/\d{2}\/\d{4}, \d{2}:\d{2}$/) !== null) { return date } + + return undefined } const customInputLength = computed(() => { diff --git a/packages/ui/src/components/Table/use-table-heights.ts b/packages/ui/src/components/Table/use-table-heights.ts index 09c24719..8b53a2a4 100644 --- a/packages/ui/src/components/Table/use-table-heights.ts +++ b/packages/ui/src/components/Table/use-table-heights.ts @@ -39,7 +39,7 @@ export function useTableHeights({ watch( [headerHeight, tableHeight], - () => { + (): void => { if (propHeight.value) { const bodyHeight = tableHeight.value - headerHeight.value @@ -54,6 +54,8 @@ export function useTableHeights({ const maxHeight = parseHeight(propMaxHeight.value) if (typeof maxHeight === 'number') { + // FIXME https://github.com/soramitsu/soramitsu-js-ui-library/issues/517 + // @ts-ignore return { 'max-height': maxHeight - headerHeight.value + 'px', } diff --git a/tsconfig.json b/tsconfig.json index 3392b584..7246d888 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, "noImplicitOverride": true, - // "noImplicitReturns": true, + "noImplicitReturns": true, "noPropertyAccessFromIndexSignature": false, // "noUncheckedIndexedAccess": true, "noUnusedLocals": false,