(ctx: TypeResolveContext)
| 71 | } |
| 72 | |
| 73 | export function extractRuntimeEmits(ctx: TypeResolveContext): Set<string> { |
| 74 | const emits = new Set<string>() |
| 75 | const node = ctx.emitsTypeDecl! |
| 76 | |
| 77 | if (node.type === 'TSFunctionType') { |
| 78 | extractEventNames(ctx, node.parameters[0], emits) |
| 79 | return emits |
| 80 | } |
| 81 | |
| 82 | const { props, calls } = resolveTypeElements(ctx, node) |
| 83 | |
| 84 | let hasProperty = false |
| 85 | for (const key in props) { |
| 86 | emits.add(key) |
| 87 | hasProperty = true |
| 88 | } |
| 89 | |
| 90 | if (calls) { |
| 91 | if (hasProperty) { |
| 92 | ctx.error( |
| 93 | `defineEmits() type cannot mixed call signature and property syntax.`, |
| 94 | node, |
| 95 | ) |
| 96 | } |
| 97 | for (const call of calls) { |
| 98 | extractEventNames(ctx, call.parameters[0], emits) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return emits |
| 103 | } |
| 104 | |
| 105 | function extractEventNames( |
| 106 | ctx: TypeResolveContext, |
no test coverage detected