|
1 |
| -import { setDevtoolsHook, ComponentPublicInstance } from 'vue' |
| 1 | +import { setDevtoolsHook, ComponentPublicInstance, devtools } from 'vue' |
2 | 2 |
|
3 | 3 | const enum DevtoolsHooks {
|
4 | 4 | COMPONENT_EMIT = 'component:emit'
|
5 | 5 | }
|
6 | 6 |
|
7 | 7 | export const attachEmitListener = (vm: ComponentPublicInstance) => {
|
8 |
| - let events: Record<string, unknown[]> = {} |
| 8 | + const events: Record<string, unknown[]> = {} |
9 | 9 | ;(vm as any).__emitted = events
|
10 |
| - // use devtools capture this "emit" |
| 10 | + // use devtools to capture this "emit" |
11 | 11 | setDevtoolsHook(createDevTools(events))
|
12 | 12 | }
|
13 | 13 |
|
14 |
| -function createDevTools(events) { |
15 |
| - const devTools: any = { |
16 |
| - emit(type, ...payload) { |
17 |
| - if (type !== DevtoolsHooks.COMPONENT_EMIT) return |
| 14 | +function createDevTools(events): any { |
| 15 | + const devTools: Partial<typeof devtools> = { |
| 16 | + emit(eventType, ...payload) { |
| 17 | + if (eventType !== DevtoolsHooks.COMPONENT_EMIT) return |
18 | 18 |
|
19 | 19 | // The first argument is root component
|
20 | 20 | // The second argument is vm
|
21 | 21 | // The third argument is event
|
22 | 22 | // The fourth argument is args of event
|
23 | 23 | recordEvent(events, payload[2], payload[3])
|
24 |
| - wrapperWarn() |
25 | 24 | }
|
26 | 25 | }
|
27 | 26 |
|
|
0 commit comments