fix: ts error

pull/6509/head
tangjinzhou 2023-04-22 22:17:17 +08:00
parent 8e5431886a
commit c36b69d7bd
11 changed files with 29 additions and 23 deletions

View File

@ -27,7 +27,14 @@ import { toArray } from './utils/typeUtil';
import { warning } from '../vc-util/warning';
import find from 'lodash-es/find';
import { tuple } from '../_util/type';
import type { InternalNamePath, Rule, RuleError, RuleObject, ValidateOptions } from './interface';
import type {
FormLabelAlign,
InternalNamePath,
Rule,
RuleError,
RuleObject,
ValidateOptions,
} from './interface';
import useConfigInject from '../_util/hooks/useConfigInject';
import { useInjectForm } from './context';
import FormItemLabel from './FormItemLabel';
@ -90,7 +97,7 @@ export const formItemProps = () => ({
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
hasFeedback: { type: Boolean, default: false },
colon: { type: Boolean, default: undefined },
labelAlign: PropTypes.oneOf(tuple('left', 'right')),
labelAlign: String as PropType<FormLabelAlign>,
prop: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
name: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
rules: [Array, Object] as PropType<Rule[] | Rule>,

View File

@ -2,13 +2,13 @@ import type { App, PropType, ExtractPropTypes } from 'vue';
import { watch, ref, defineComponent } from 'vue';
import classNames from '../_util/classNames';
import PropTypes from '../_util/vue-types';
import VcMentions, { Option } from '../vc-mentions';
import VcMentions from '../vc-mentions';
import { mentionsProps as baseMentionsProps } from '../vc-mentions/src/mentionsProps';
import useConfigInject from '../_util/hooks/useConfigInject';
import { flattenChildren, getOptionProps } from '../_util/props-util';
import { useInjectFormItemContext } from '../form/FormItemContext';
import omit from '../_util/omit';
import { optionProps } from '../vc-mentions/src/Option';
import { optionProps, optionOptions } from '../vc-mentions/src/Option';
import type { KeyboardEventHandler } from '../_util/EventInterface';
interface MentionsConfig {
@ -206,7 +206,7 @@ const Mentions = defineComponent({
/* istanbul ignore next */
export const MentionsOption = defineComponent({
compatConfig: { MODE: 3 },
...Option,
...optionOptions,
name: 'AMentionsOption',
props: optionProps,
});

View File

@ -2,7 +2,6 @@ import Table, { tableProps } from './Table';
import Column from './Column';
import ColumnGroup from './ColumnGroup';
import type { TableProps, TablePaginationConfig } from './Table';
import { defineComponent } from 'vue';
import type { App } from 'vue';
import { EXPAND_COLUMN, Summary, SummaryCell, SummaryRow } from '../vc-table';
import {
@ -16,8 +15,8 @@ export type { ColumnProps } from './Column';
export type { ColumnsType, ColumnType, ColumnGroupType } from './interface';
export type { TableProps, TablePaginationConfig };
const TableSummaryRow = defineComponent({ ...SummaryRow, name: 'ATableSummaryRow' });
const TableSummaryCell = defineComponent({ ...SummaryCell, name: 'ATableSummaryCell' });
const TableSummaryRow = SummaryRow;
const TableSummaryCell = SummaryCell;
const TableSummary = Object.assign(Summary, {
Cell: TableSummaryCell,

View File

@ -1,9 +1,7 @@
import type { App } from 'vue';
import { defineComponent } from 'vue';
import Tree from './Tree';
import { TreeNode as VcTreeNode } from '../vc-tree';
import DirectoryTree from './DirectoryTree';
import { treeNodeProps } from '../vc-tree/props';
export type { EventDataNode, DataNode } from '../vc-tree/interface';
@ -26,7 +24,7 @@ export type {
/* istanbul ignore next */
const TreeNode = defineComponent({ ...VcTreeNode, name: 'ATreeNode', props: treeNodeProps });
const TreeNode = VcTreeNode;
export { DirectoryTree, TreeNode };

View File

@ -45,7 +45,10 @@ export const listItemProps = () => {
onPreview: Function as PropType<(file: UploadFile, e: Event) => void>,
onClose: Function as PropType<(file: UploadFile) => void>,
onDownload: Function as PropType<(file: UploadFile) => void>,
progress: Object as PropType<UploadListProgressProps>,
progress: {
type: Object as PropType<UploadListProgressProps>,
default: undefined as UploadListProgressProps,
},
};
};

View File

@ -8,12 +8,14 @@ export const optionProps = {
};
export type OptionProps = Partial<ExtractPropTypes<typeof optionProps>>;
export default defineComponent({
compatConfig: { MODE: 3 },
export const optionOptions = {
name: 'Option',
props: optionProps,
render(_props: any, { slots }: any) {
return slots.default?.();
},
};
export default defineComponent({
compatConfig: { MODE: 3 },
...optionOptions,
});

View File

@ -13,7 +13,7 @@ export interface SummaryCellProps {
}
export default defineComponent<SummaryCellProps>({
name: 'SummaryCell',
name: 'ATableSummaryCell',
props: ['index', 'colSpan', 'rowSpan', 'align'] as any,
setup(props, { attrs, slots }) {
const tableContext = useInjectTable();

View File

@ -2,7 +2,7 @@ import { defineComponent } from 'vue';
export default defineComponent({
compatConfig: { MODE: 3 },
name: 'FooterRow',
name: 'ATableSummaryRow',
setup(_props, { slots }) {
return () => <tr>{slots.default?.()}</tr>;
},

View File

@ -25,7 +25,7 @@ const defaultTitle = '---';
export default defineComponent({
compatConfig: { MODE: 3 },
name: 'TreeNode',
name: 'ATreeNode',
inheritAttrs: false,
props: treeNodeProps,
isTreeNode: 1,
@ -293,7 +293,7 @@ export default defineComponent({
// ==================== Render: Drag Handler ====================
const renderDragHandler = () => {
const { draggable, prefixCls } = context.value;
return draggable?.icon ? (
return draggable && draggable?.icon ? (
<span class={`${prefixCls}-draggable-icon`}>{draggable.icon}</span>
) : null;
};

View File

@ -40,7 +40,7 @@ export interface TreeContextProps {
showIcon: boolean;
icon: IconType;
switcherIcon: IconType;
draggable: DraggableConfig;
draggable: DraggableConfig | false;
draggingNodeKey?: Key;
checkable: boolean;
customCheckable: () => any;

View File

@ -1,7 +1,6 @@
export function isZhCN(name) {
return /-cn\/?$/.test(name);
}
export function isLocalStorageNameSupported() {
const testKey = 'test';
const storage = window.localStorage;
@ -13,7 +12,6 @@ export function isLocalStorageNameSupported() {
return false;
}
}
export function getLocalizedPathname(path, zhCN, query = {}, hash) {
const pathname = path.startsWith('/') ? path : `/${path}`;
let fullPath;
@ -27,7 +25,6 @@ export function getLocalizedPathname(path, zhCN, query = {}, hash) {
} else {
fullPath = `${pathname}-cn`;
}
if (hash) {
const localHash = hash[zhCN ? 'zhCN' : 'enUS'];
fullPath += `#${localHash}`;