Home / Function/ assertType() — vue Function Reference

assertType() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  0e75b5c0_cbef_bb97_2108_927f30ffcea6["assertType()"]
  dcde110b_8854_c944_bfb4_3d5581f6359e["assertProp()"]
  dcde110b_8854_c944_bfb4_3d5581f6359e -->|calls| 0e75b5c0_cbef_bb97_2108_927f30ffcea6
  e637891d_285c_15ea_8a69_13f420f671c0["getType()"]
  0e75b5c0_cbef_bb97_2108_927f30ffcea6 -->|calls| e637891d_285c_15ea_8a69_13f420f671c0
  9fc168ea_48e1_435f_dc4f_5cd5efd8ba0e["isPlainObject()"]
  0e75b5c0_cbef_bb97_2108_927f30ffcea6 -->|calls| 9fc168ea_48e1_435f_dc4f_5cd5efd8ba0e
  a8c8f192_fd2d_dbe3_46ed_dd8fabebc429["warn()"]
  0e75b5c0_cbef_bb97_2108_927f30ffcea6 -->|calls| a8c8f192_fd2d_dbe3_46ed_dd8fabebc429
  style 0e75b5c0_cbef_bb97_2108_927f30ffcea6 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