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 CoreRuntime Observer calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  9aa11e66_4392_8ac7_ac29_01fd54a3d105["assertType()"]
  e8576a88_2e85_86ff_b2f9_bbbb6de70a51["props.ts"]
  9aa11e66_4392_8ac7_ac29_01fd54a3d105 -->|defined in| e8576a88_2e85_86ff_b2f9_bbbb6de70a51
  d12d8448_7216_80ce_8a3d_b515beeca7cf["assertProp()"]
  d12d8448_7216_80ce_8a3d_b515beeca7cf -->|calls| 9aa11e66_4392_8ac7_ac29_01fd54a3d105
  f5fda3f6_b160_81e4_ce76_ab6eb1b1fa39["getType()"]
  9aa11e66_4392_8ac7_ac29_01fd54a3d105 -->|calls| f5fda3f6_b160_81e4_ce76_ab6eb1b1fa39
  e8b22500_20a5_2e19_4c79_386004841499["warn()"]
  9aa11e66_4392_8ac7_ac29_01fd54a3d105 -->|calls| e8b22500_20a5_2e19_4c79_386004841499
  style 9aa11e66_4392_8ac7_ac29_01fd54a3d105 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, defined in src/core/util/props.ts.
Where is assertType() defined?
assertType() is defined in src/core/util/props.ts at line 151.
What does assertType() call?
assertType() calls 2 function(s): getType, 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