Home / Function/ assertType() — vue Function Reference

assertType() — vue Function Reference

Architecture documentation for the assertType() function in props.ts from the vue codebase.

Function typescript CoreInstance VDOM calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  a932425d_6366_3fdb_331a_b75977c60593["assertType()"]
  87f7db47_5b28_fa14_0778_0d908fd6f104["assertProp()"]
  87f7db47_5b28_fa14_0778_0d908fd6f104 -->|calls| a932425d_6366_3fdb_331a_b75977c60593
  fbb240de_965a_91cc_941c_3973c9ae84a4["getType()"]
  a932425d_6366_3fdb_331a_b75977c60593 -->|calls| fbb240de_965a_91cc_941c_3973c9ae84a4
  80bfcce4_fe50_33ea_903d_c2ad718873ba["isPlainObject()"]
  a932425d_6366_3fdb_331a_b75977c60593 -->|calls| 80bfcce4_fe50_33ea_903d_c2ad718873ba
  e3484a9f_f8a5_4082_0208_641d58b965c3["warn()"]
  a932425d_6366_3fdb_331a_b75977c60593 -->|calls| e3484a9f_f8a5_4082_0208_641d58b965c3
  style a932425d_6366_3fdb_331a_b75977c60593 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/util/props.ts lines 151–184

function assertType(
  value: any,
  type: Function,
  vm?: Component
): {
  valid: boolean
  expectedType: string
} {
  let valid
  const expectedType = getType(type)
  if (simpleCheckRE.test(expectedType)) {
    const t = typeof value
    valid = t === expectedType.toLowerCase()
    // for primitive wrapper objects
    if (!valid && t === 'object') {
      valid = value instanceof type
    }
  } else if (expectedType === 'Object') {
    valid = isPlainObject(value)
  } else if (expectedType === 'Array') {
    valid = isArray(value)
  } else {
    try {
      valid = value instanceof type
    } catch (e: any) {
      warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm)
      valid = false
    }
  }
  return {
    valid,
    expectedType
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does assertType() do?
assertType() is a function in the vue codebase.
What does assertType() call?
assertType() calls 3 function(s): getType, isPlainObject, warn.
What calls assertType()?
assertType() is called by 1 function(s): assertProp.

Analyze Your Own Codebase

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

Try Supermodel Free