Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 53e1812

Browse files
fix: fix type of function byPassAllModalEvents
1 parent 507b6c8 commit 53e1812

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

‎packages/vue-final-modal/src/useApi.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { tryOnUnmounted } from '@vueuse/core'
44
import VueFinalModal from './components/VueFinalModal/VueFinalModal.vue'
55
import type { ModalSlotOptions, UseModalOptions, UseModalOptionsPrivate, UseModalReturnType, Vfm } from './Modal'
66
import { activeVfm, getActiveVfm } from './plugin'
7-
import type { ComponentProps } from './Component'
7+
import type { ComponentEmit,ComponentProps } from './Component'
88
import { isString, objectEntries } from '~/utils'
99

1010
/**
@@ -187,32 +187,30 @@ export function isModalSlotOptions(value: unknown): value is ModalSlotOptions {
187187
return false
188188
}
189189

190-
export function pickModalProps(props: any, modalProps: any) {
191-
return Object.keys(modalProps).reduce((acc, propName) => {
192-
acc[propName] = props[propName]
190+
export function pickModalProps(props: Record<string,any>, modalProps: Record<string,any>) {
191+
return Object.keys(modalProps).reduce<Record<string,any>>((acc, propName) => {
192+
acc[propName] = props?.[propName]
193193
return acc
194-
}, {}asRecord<string,any>)
194+
}, {})
195195
}
196196

197-
export function byPassAllModalEvents(emit?: InstanceType<typeof VueFinalModal>['$emit']) {
198-
if (!emit)
199-
return {}
197+
export function byPassAllModalEvents(emit?: ComponentEmit<typeof VueFinalModal>): ComponentProps<typeof VueFinalModal> {
200198
return {
201-
'onUpdate:modelValue': (val: boolean) => emit('update:modelValue', val),
199+
'onUpdate:modelValue': (val: boolean) => emit?.('update:modelValue', val),
202200

203-
'onBeforeClose': (payload: { stop: () => void }) => emit('beforeClose', payload),
204-
'onClosed': () => emit('closed'),
205-
'onBeforeOpen': (payload: { stop: () => void }) => emit('beforeOpen', payload),
206-
'onOpened': () => emit('opened'),
201+
'onBeforeClose': (payload: { stop: () => void }) => emit?.('beforeClose', payload),
202+
'onClosed': () => emit?.('closed'),
203+
'onBeforeOpen': (payload: { stop: () => void }) => emit?.('beforeOpen', payload),
204+
'onOpened': () => emit?.('opened'),
207205

208206
/** onClickOutside will only be emitted when clickToClose equal to `false` */
209-
'onClickOutside': () => emit('clickOutside'),
207+
'onClickOutside': () => emit?.('clickOutside'),
210208
}
211209
}
212210

213-
export function useVfmAttrs(options: {
214-
props: Record<any,any>
215-
modalProps: Record<any,any>
211+
export function useVfmAttrs<TPextendsComponent,MPextendsComponent>(options: {
212+
props: ComponentProps<TP>
213+
modalProps: ComponentProps<MP>
216214
emit?: any
217215
}) {
218216
const { props, modalProps, emit } = options

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /