mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types(utils): pick type (#8179)
This commit is contained in:
parent
d67031a98d
commit
8696f4ee70
@ -50,7 +50,9 @@ export default createComponent({
|
|||||||
emits: ['select', 'cancel', 'update:show'],
|
emits: ['select', 'cancel', 'update:show'],
|
||||||
|
|
||||||
setup(props, { slots, emit }) {
|
setup(props, { slots, emit }) {
|
||||||
const popupPropKeys = Object.keys(popupSharedProps);
|
const popupPropKeys = Object.keys(popupSharedProps) as Array<
|
||||||
|
keyof typeof popupSharedProps
|
||||||
|
>;
|
||||||
|
|
||||||
const onUpdateShow = (show: boolean) => {
|
const onUpdateShow = (show: boolean) => {
|
||||||
emit('update:show', show);
|
emit('update:show', show);
|
||||||
|
@ -18,10 +18,10 @@ export type DialogAction = 'confirm' | 'cancel';
|
|||||||
export type DialogMessageAlign = 'left' | 'center' | 'right';
|
export type DialogMessageAlign = 'left' | 'center' | 'right';
|
||||||
|
|
||||||
const popupKeys = [
|
const popupKeys = [
|
||||||
...Object.keys(popupSharedProps),
|
...(Object.keys(popupSharedProps) as Array<keyof typeof popupSharedProps>),
|
||||||
'transition',
|
'transition',
|
||||||
'closeOnPopstate',
|
'closeOnPopstate',
|
||||||
];
|
] as const;
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
props: {
|
props: {
|
||||||
|
@ -105,7 +105,7 @@ export default createComponent({
|
|||||||
'clearable',
|
'clearable',
|
||||||
'modelValue',
|
'modelValue',
|
||||||
'clearTrigger',
|
'clearTrigger',
|
||||||
];
|
] as const;
|
||||||
|
|
||||||
const renderField = () => {
|
const renderField = () => {
|
||||||
const fieldAttrs = {
|
const fieldAttrs = {
|
||||||
|
@ -38,9 +38,9 @@ export function get(object: any, path: string): any {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pick(obj: Record<string, any>, keys: string[]) {
|
export function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>) {
|
||||||
return keys.reduce((ret, key) => {
|
return keys.reduce((ret, key) => {
|
||||||
ret[key] = obj[key];
|
ret[key] = obj[key];
|
||||||
return ret;
|
return ret;
|
||||||
}, {} as Record<string, any>);
|
}, {} as Pick<T, U>);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user