MCPcopy
hub / github.com/vuejs/core / extractRuntimeEmits

Function extractRuntimeEmits

packages/compiler-sfc/src/script/defineEmits.ts:73–103  ·  view source on GitHub ↗
(ctx: TypeResolveContext)

Source from the content-addressed store, hash-verified

71}
72
73export 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
105function extractEventNames(
106 ctx: TypeResolveContext,

Callers 1

genRuntimeEmitsFunction · 0.85

Calls 3

resolveTypeElementsFunction · 0.90
extractEventNamesFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected