types: improve relation types (#9016)

This commit is contained in:
neverland
2021-07-12 20:54:19 +08:00
committed by GitHub
parent aedb8543e6
commit 0e05d8c908
28 changed files with 146 additions and 108 deletions
+12 -2
View File
@@ -55,6 +55,16 @@ import type {
const [name, bem] = createNamespace('field');
// Shared props of Field and Form
type SharedProps =
| 'colon'
| 'disabled'
| 'readonly'
| 'labelWidth'
| 'labelAlign'
| 'inputAlign'
| 'errorMessageAlign';
// provide to Search component to inherit
export const fieldProps = {
formatter: Function as PropType<(value: string) => string>,
@@ -141,11 +151,11 @@ export default defineComponent({
const inputRef = ref<HTMLInputElement>();
const childFieldValue = ref<() => unknown>();
const { parent: form } = useParent<any>(FORM_KEY);
const { parent: form } = useParent(FORM_KEY);
const getModelValue = () => String(props.modelValue ?? '');
const getProp = (key: keyof typeof props) => {
const getProp = <T extends SharedProps>(key: T) => {
if (isDef(props[key])) {
return props[key];
}