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
  7a13ff4e_4260_4a99_9589_83a4aaf232c3["extractEventNames()"]
  f18d0d77_a105_150e_afc9_0fbde80a6a72["extractRuntimeEmits()"]
  f18d0d77_a105_150e_afc9_0fbde80a6a72 -->|calls| 7a13ff4e_4260_4a99_9589_83a4aaf232c3
  style 7a13ff4e_4260_4a99_9589_83a4aaf232c3 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