Home / Function/ extractEventNames() — vue Function Reference

extractEventNames() — vue Function Reference

Architecture documentation for the extractEventNames() function in compileScript.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  26cea459_6c54_a77a_7008_f7ee22907cc3["extractEventNames()"]
  b9f12a63_b611_1b00_0717_3ff21d7ce156["compileScript.ts"]
  26cea459_6c54_a77a_7008_f7ee22907cc3 -->|defined in| b9f12a63_b611_1b00_0717_3ff21d7ce156
  79bd275c_700e_05b7_5cee_14fb4e1f3f21["extractRuntimeEmits()"]
  79bd275c_700e_05b7_5cee_14fb4e1f3f21 -->|calls| 26cea459_6c54_a77a_7008_f7ee22907cc3
  style 26cea459_6c54_a77a_7008_f7ee22907cc3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/compiler-sfc/src/compileScript.ts lines 1577–1606

function extractEventNames(
  eventName: ArrayPattern | Identifier | ObjectPattern | RestElement,
  emits: Set<string>
) {
  if (
    eventName.type === 'Identifier' &&
    eventName.typeAnnotation &&
    eventName.typeAnnotation.type === 'TSTypeAnnotation'
  ) {
    const typeNode = eventName.typeAnnotation.typeAnnotation
    if (typeNode.type === 'TSLiteralType') {
      if (
        typeNode.literal.type !== 'UnaryExpression' &&
        typeNode.literal.type !== 'TemplateLiteral'
      ) {
        emits.add(String(typeNode.literal.value))
      }
    } else if (typeNode.type === 'TSUnionType') {
      for (const t of typeNode.types) {
        if (
          t.type === 'TSLiteralType' &&
          t.literal.type !== 'UnaryExpression' &&
          t.literal.type !== 'TemplateLiteral'
        ) {
          emits.add(String(t.literal.value))
        }
      }
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does extractEventNames() do?
extractEventNames() is a function in the vue codebase, defined in packages/compiler-sfc/src/compileScript.ts.
Where is extractEventNames() defined?
extractEventNames() is defined in packages/compiler-sfc/src/compileScript.ts at line 1577.
What calls extractEventNames()?
extractEventNames() is called by 1 function(s): extractRuntimeEmits.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free