Home / File/ error-detector.ts — vue Source File

error-detector.ts — vue Source File

Architecture documentation for error-detector.ts, a typescript file in the vue codebase. 2 imports, 1 dependents.

File typescript VueCore VDom 2 imports 1 dependents 7 functions

Entity Profile

Dependency Diagram

graph LR
  082d4686_2778_e118_a80c_c4ffc89177dc["error-detector.ts"]
  101d3d34_ac07_228f_62b9_5d5ac4a0ea2e["index.ts"]
  082d4686_2778_e118_a80c_c4ffc89177dc --> 101d3d34_ac07_228f_62b9_5d5ac4a0ea2e
  a80b8e3b_d720_9146_3bf6_594d4ee5dd77["compiler"]
  082d4686_2778_e118_a80c_c4ffc89177dc --> a80b8e3b_d720_9146_3bf6_594d4ee5dd77
  ff1da07c_8f38_b75f_ad5a_42883a44a3df["create-compiler.ts"]
  ff1da07c_8f38_b75f_ad5a_42883a44a3df --> 082d4686_2778_e118_a80c_c4ffc89177dc
  style 082d4686_2778_e118_a80c_c4ffc89177dc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { ASTElement, ASTNode } from 'types/compiler'
import { dirRE, onRE } from './parser/index'

type Range = { start?: number; end?: number }

// these keywords should not appear inside expressions, but operators like
// typeof, instanceof and in are allowed
const prohibitedKeywordRE = new RegExp(
  '\\b' +
    (
      'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
      'super,throw,while,yield,delete,export,import,return,switch,default,' +
      'extends,finally,continue,debugger,function,arguments'
    )
      .split(',')
      .join('\\b|\\b') +
    '\\b'
)

// these unary operators should not be used as property/method names
const unaryOperatorsRE = new RegExp(
  '\\b' +
    'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
    '\\s*\\([^\\)]*\\)'
)

// strip strings in expressions
const stripStringRE =
  /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g

// detect problematic expressions in a template
export function detectErrors(ast: ASTNode | undefined, warn: Function) {
  if (ast) {
    checkNode(ast, warn)
  }
}

function checkNode(node: ASTNode, warn: Function) {
  if (node.type === 1) {
    for (const name in node.attrsMap) {
      if (dirRE.test(name)) {
        const value = node.attrsMap[name]
        if (value) {
          const range = node.rawAttrsMap[name]
          if (name === 'v-for') {
            checkFor(node, `v-for="${value}"`, warn, range)
          } else if (name === 'v-slot' || name[0] === '#') {
            checkFunctionParameterExpression(
              value,
              `${name}="${value}"`,
              warn,
              range
            )
          } else if (onRE.test(name)) {
            checkEvent(value, `${name}="${value}"`, warn, range)
          } else {
            checkExpression(value, `${name}="${value}"`, warn, range)
          }
        }
      }
// ... (99 more lines)

Domain

Subdomains

Types

Dependencies

Frequently Asked Questions

What does error-detector.ts do?
error-detector.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, VDom subdomain.
What functions are defined in error-detector.ts?
error-detector.ts defines 7 function(s): checkEvent, checkExpression, checkFor, checkFunctionParameterExpression, checkIdentifier, checkNode, detectErrors.
What does error-detector.ts depend on?
error-detector.ts imports 2 module(s): compiler, index.ts.
What files import error-detector.ts?
error-detector.ts is imported by 1 file(s): create-compiler.ts.
Where is error-detector.ts in the architecture?
error-detector.ts is located at src/compiler/error-detector.ts (domain: VueCore, subdomain: VDom, directory: src/compiler).

Analyze Your Own Codebase

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

Try Supermodel Free