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
  7d90088e_d156_a8b8_031f_2ed067b0525e["extractEventNames()"]
  be219160_436f_73bf_042a_998cc1d932a1["extractRuntimeEmits()"]
  be219160_436f_73bf_042a_998cc1d932a1 -->|calls| 7d90088e_d156_a8b8_031f_2ed067b0525e
  style 7d90088e_d156_a8b8_031f_2ed067b0525e 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.
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