bowen
2023-10-10 30b3ee5c89c31cb5794faab40e800c36507d258a
chore: fix type:check error (#3126)

* chore: Fix ts type error

* chore: fix type:check error
13个文件已修改
82 ■■■■■ 已修改文件
packages/types/src/utils.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Form/src/BasicForm.vue 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Form/src/components/ApiTree.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Table/src/components/editable/CellComponent.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Transition/src/CreateTransition.tsx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Tree/src/TreeIcon.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Tree/src/components/TreeHeader.vue 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layouts/default/setting/components/SelectItem.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layouts/default/setting/components/SwitchItem.vue 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/demo/editor/json/index.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/demo/form/index.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/demo/table/FormTable.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
types/index.d.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/types/src/utils.ts
@@ -26,7 +26,7 @@
/**
 * 字符串类型对象
 */
type Recordable<T> = Record<string, T>;
type Recordable<T = any> = Record<string, T>;
/**
 * 字符串类型对象(只读)
src/components/Form/src/BasicForm.vue
@@ -43,7 +43,7 @@
  import type { Ref } from 'vue';
  import { defineComponent, reactive, ref, computed, unref, onMounted, watch, nextTick } from 'vue';
  import { Form, Row } from 'ant-design-vue';
  import { Form, Row, type FormProps as AntFormProps } from 'ant-design-vue';
  import FormItem from './components/FormItem.vue';
  import FormAction from './components/FormAction.vue';
@@ -112,7 +112,9 @@
        };
      });
      const getBindValue = computed(() => ({ ...attrs, ...props, ...unref(getProps) }));
      const getBindValue = computed(
        () => ({ ...attrs, ...props, ...unref(getProps) }) as AntFormProps,
      );
      const getSchema = computed((): FormSchema[] => {
        const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
@@ -303,7 +305,10 @@
        formActionType: formActionType as any,
        setFormModel,
        getFormClass,
        getFormActionBindProps: computed(() => ({ ...getProps.value, ...advanceState })),
        getFormActionBindProps: computed(
          () =>
            ({ ...getProps.value, ...advanceState }) as InstanceType<typeof FormAction>['$props'],
        ),
        fieldsIsAdvancedMap,
        ...formActionType,
      };
src/components/Form/src/components/ApiTree.vue
@@ -79,7 +79,7 @@
        if (!isArray(result)) {
          result = get(result, props.resultField);
        }
        treeData.value = (result as Recordable<any>[]) || [];
        treeData.value = (result as (Recordable & { key: string | number })[]) || [];
        isFirstLoaded.value = true;
        emit('options-change', treeData.value);
      }
src/components/Table/src/components/editable/CellComponent.ts
@@ -1,4 +1,4 @@
import type { FunctionalComponent, defineComponent } from 'vue';
import type { defineComponent } from 'vue';
import type { ComponentType } from '../../types/componentType';
import { componentMap } from '/@/components/Table/src/componentMap';
@@ -13,7 +13,7 @@
  getPopupContainer?: Fn;
}
export const CellComponent: FunctionalComponent = (
export const CellComponent = (
  {
    component = 'Input',
    rule = true,
src/components/Transition/src/CreateTransition.tsx
@@ -23,8 +23,8 @@
      },
    },
    setup(props, { slots, attrs }) {
      const onBeforeEnter = (el: HTMLElement) => {
        el.style.transformOrigin = props.origin;
      const onBeforeEnter = (el: Element) => {
        (el as HTMLElement).style.transformOrigin = props.origin;
      };
      return () => {
src/components/Tree/src/TreeIcon.ts
@@ -1,9 +1,9 @@
import type { VNode, FunctionalComponent } from 'vue';
import type { VNode } from 'vue';
import { h } from 'vue';
import { isString } from 'lodash-es';
import Icon from '@/components/Icon/Icon.vue';
export const TreeIcon: FunctionalComponent = ({ icon }: { icon: VNode | string }) => {
export const TreeIcon = ({ icon }: { icon: VNode | string }) => {
  if (!icon) return null;
  if (isString(icon)) {
    return h(Icon, { icon, class: 'mr-1' });
src/components/Tree/src/components/TreeHeader.vue
@@ -34,7 +34,14 @@
</template>
<script lang="ts" setup>
  import { type PropType, computed, ref, watch, useSlots } from 'vue';
  import { Dropdown, Menu, MenuItem, MenuDivider, InputSearch } from 'ant-design-vue';
  import {
    Dropdown,
    Menu,
    MenuItem,
    MenuDivider,
    InputSearch,
    type MenuProps,
  } from 'ant-design-vue';
  import Icon from '@/components/Icon/Icon.vue';
  import { BasicTitle } from '/@/components/Basic';
  import { useI18n } from '/@/hooks/web/useI18n';
@@ -122,8 +129,7 @@
      : defaultToolbarList;
  });
  function handleMenuClick(e: { key: ToolbarEnum }) {
    const { key } = e;
  const handleMenuClick: MenuProps['onClick'] = ({ key }) => {
    switch (key) {
      case ToolbarEnum.SELECT_ALL:
        props.checkAll?.(true);
@@ -144,7 +150,7 @@
        emit('strictly-change', true);
        break;
    }
  }
  };
  function emitChange(value?: string): void {
    emit('search', value);
src/layouts/default/setting/components/SelectItem.vue
@@ -14,7 +14,7 @@
<script lang="ts">
  import { defineComponent, PropType, computed } from 'vue';
  import { Select } from 'ant-design-vue';
  import { Select, type SelectProps } from 'ant-design-vue';
  import { useDesign } from '/@/hooks/web/useDesign';
  import { baseHandler } from '../handler';
  import { HandlerEnum } from '../enum';
@@ -49,9 +49,10 @@
        return props.def ? { value: props.def, defaultValue: props.initValue || props.def } : {};
      });
      function handleChange(e: ChangeEvent) {
        props.event && baseHandler(props.event, e);
      }
      const handleChange: SelectProps['onChange'] = (val) => {
        props.event && baseHandler(props.event, val);
      };
      return {
        prefixCls,
        handleChange,
src/layouts/default/setting/components/SwitchItem.vue
@@ -13,7 +13,7 @@
<script lang="ts">
  import { defineComponent, PropType, computed } from 'vue';
  import { Switch } from 'ant-design-vue';
  import { Switch, type SwitchProps } from 'ant-design-vue';
  import { useDesign } from '/@/hooks/web/useDesign';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { baseHandler } from '../handler';
@@ -43,9 +43,11 @@
      const getBindValue = computed(() => {
        return props.def ? { checked: props.def } : {};
      });
      function handleChange(e: ChangeEvent) {
        props.event && baseHandler(props.event, e);
      }
      const handleChange: SwitchProps['onChange'] = (val) => {
        props.event && baseHandler(props.event, val);
      };
      return {
        prefixCls,
        t,
src/views/demo/editor/json/index.vue
@@ -17,7 +17,7 @@
  import { defineComponent, ref, unref, h } from 'vue';
  import { CodeEditor, JsonPreview, MODE } from '/@/components/CodeEditor';
  import { PageWrapper } from '/@/components/Page';
  import { Radio, Space, Modal } from 'ant-design-vue';
  import { Radio, Space, Modal, type RadioGroupProps } from 'ant-design-vue';
  const jsonData =
    '{"name":"BeJson","url":"http://www.xxx.com","page":88,"isNonProfit":true,"address":{"street":"科技园路.","city":"江苏苏州","country":"中国"},"links":[{"name":"Google","url":"http://www.xxx.com"},{"name":"Baidu","url":"http://www.xxx.com"},{"name":"SoSo","url":"http://www.xxx.com"}]}';
@@ -65,7 +65,7 @@
      const modeValue = ref<MODE>(MODE.JSON);
      const value = ref(jsonData);
      function handleModeChange(e: ChangeEvent) {
      const handleModeChange: RadioGroupProps['onChange'] = (e) => {
        const mode = e.target.value;
        if (mode === MODE.JSON) {
          value.value = jsonData;
@@ -79,7 +79,7 @@
          value.value = jsData;
          return;
        }
      }
      };
      function showData() {
        if (unref(modeValue) === 'application/json') {
src/views/demo/form/index.vue
@@ -66,25 +66,25 @@
  import { optionsListApi } from '/@/api/demo/select';
  import { useDebounceFn } from '@vueuse/core';
  import { treeOptionsListApi } from '/@/api/demo/tree';
  import { Select } from 'ant-design-vue';
  import { Select, type SelectProps } from 'ant-design-vue';
  import { cloneDeep } from 'lodash-es';
  import { areaRecord } from '/@/api/demo/cascader';
  import { uploadApi } from '/@/api/sys/upload';
  const valueSelectA = ref<string[]>([]);
  const valueSelectB = ref<string[]>([]);
  const options = ref<Recordable[]>([]);
  const options = ref<Required<SelectProps>['options']>([]);
  for (let i = 1; i < 10; i++) options.value.push({ label: '选项' + i, value: `${i}` });
  const optionsA = computed(() => {
    return cloneDeep(unref(options)).map((op) => {
      op.disabled = unref(valueSelectB).indexOf(op.value) !== -1;
      op.disabled = unref(valueSelectB).indexOf(op.value as string) !== -1;
      return op;
    });
  });
  const optionsB = computed(() => {
    return cloneDeep(unref(options)).map((op) => {
      op.disabled = unref(valueSelectA).indexOf(op.value) !== -1;
      op.disabled = unref(valueSelectA).indexOf(op.value as string) !== -1;
      return op;
    });
  });
@@ -705,7 +705,7 @@
      const check = ref(null);
      const { createMessage } = useMessage();
      const keyword = ref<string>('');
      const searchParams = computed<Recordable>(() => {
      const searchParams = computed<Recordable<string>>(() => {
        return { keyword: unref(keyword) };
      });
src/views/demo/table/FormTable.vue
@@ -20,7 +20,7 @@
  </BasicTable>
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { defineComponent, ref, unref } from 'vue';
  import { BasicTable, useTable } from '/@/components/Table';
  import { getBasicColumns, getFormConfig } from './tableData';
  import { Alert } from 'ant-design-vue';
@@ -43,7 +43,7 @@
        rowKey: 'id',
        rowSelection: {
          type: 'checkbox',
          selectedRowKeys: checkedKeys,
          selectedRowKeys: unref(checkedKeys),
          onSelect: onSelect,
          onSelectAll: onSelectAll,
        },
types/index.d.ts
@@ -14,7 +14,7 @@
  [key: string]: string | number | boolean;
}[];
declare type EmitType = (event: string, ...args: any[]) => void;
declare type EmitType = ReturnType<typeof defineEmits>;
declare type TargetContext = '_self' | '_blank';