mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-18 10:59:10 +08:00
wip
This commit is contained in:
parent
6c6e4c67e2
commit
69d2573430
@ -1,3 +1,4 @@
|
||||
import { defineComponent } from 'vue'
|
||||
import { placements } from '@popperjs/core'
|
||||
import { CommonProps } from '@element-plus/components/cascader-panel'
|
||||
import { buildProps, definePropType, isBoolean } from '@element-plus/utils'
|
||||
@ -158,3 +159,34 @@ export const cascaderEmits = {
|
||||
// export type CascaderProps = ExtractPropTypes<typeof cascaderProps>
|
||||
|
||||
export type CascaderEmits = typeof cascaderEmits
|
||||
|
||||
const fooProps = buildProps({
|
||||
valueOnClear: {
|
||||
type: [String, Number, Boolean, Function] as const,
|
||||
},
|
||||
b: [String, Number, Boolean, Function] as const,
|
||||
})
|
||||
|
||||
const a = {
|
||||
type: [String, Number, Boolean, Function],
|
||||
default: undefined,
|
||||
}
|
||||
const b = {
|
||||
type: [String, Number, Boolean, Function],
|
||||
default: undefined,
|
||||
} as const
|
||||
|
||||
defineComponent({
|
||||
props: {
|
||||
a: {
|
||||
type: [String, Number, Boolean, Function] as const,
|
||||
},
|
||||
},
|
||||
})
|
||||
const c = {
|
||||
props: {
|
||||
a: {
|
||||
type: [String, Number, Boolean, Function] as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { warn } from 'vue'
|
||||
import { fromPairs } from 'lodash-unified'
|
||||
import { requiredNumber } from '@element-plus/components/table-v2/src/common'
|
||||
import { isObject } from '../../types'
|
||||
import { hasOwn } from '../../objects'
|
||||
|
||||
@ -101,18 +102,12 @@ export const buildProp = <
|
||||
export const buildProps = <
|
||||
Props extends Record<
|
||||
string,
|
||||
| { [epPropKey]: true }
|
||||
| NativePropType
|
||||
| EpPropInput<any, any, any, any, any>
|
||||
PropType<any> | EpPropInput<any, any, any, any, any>
|
||||
>
|
||||
>(
|
||||
props: Props
|
||||
): {
|
||||
[K in keyof Props]: IfEpProp<
|
||||
Props[K],
|
||||
Props[K],
|
||||
IfNativePropType<Props[K], Props[K], EpPropConvert<Props[K]>>
|
||||
>
|
||||
[K in keyof Props]: B<Props[K]>
|
||||
} =>
|
||||
fromPairs(
|
||||
Object.entries(props).map(([key, option]) => [
|
||||
@ -120,3 +115,22 @@ export const buildProps = <
|
||||
buildProp(option as any, key),
|
||||
])
|
||||
) as any
|
||||
|
||||
type B<Prop> = Prop extends PropType<infer Type>
|
||||
? PropType<Type>
|
||||
: Prop extends { type: PropType<infer Type> }
|
||||
? Prop extends { required: true }
|
||||
? { type: PropType<Type>; required: true }
|
||||
: { type: PropType<Type> }
|
||||
: never
|
||||
|
||||
type Test = {
|
||||
readonly type: readonly [
|
||||
StringConstructor,
|
||||
NumberConstructor,
|
||||
BooleanConstructor,
|
||||
FunctionConstructor
|
||||
]
|
||||
} extends { type: PropType<infer Type> }
|
||||
? true
|
||||
: false
|
||||
|
Loading…
Reference in New Issue
Block a user