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 VueCore Instance calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  14d92bc1_ead1_09a4_f147_3d6283934bf2["assertType()"]
  ebb0510e_1beb_0f1e_d9b5_9f9e319cefcc["props.ts"]
  14d92bc1_ead1_09a4_f147_3d6283934bf2 -->|defined in| ebb0510e_1beb_0f1e_d9b5_9f9e319cefcc
  bdff343d_a655_05a3_a87d_d14305aacd8d["assertProp()"]
  bdff343d_a655_05a3_a87d_d14305aacd8d -->|calls| 14d92bc1_ead1_09a4_f147_3d6283934bf2
  089784d1_bec2_cac1_11c8_a234cf70796b["getType()"]
  14d92bc1_ead1_09a4_f147_3d6283934bf2 -->|calls| 089784d1_bec2_cac1_11c8_a234cf70796b
  48bc61b1_05ca_3121_50a7_2f02cdcf2f03["warn()"]
  14d92bc1_ead1_09a4_f147_3d6283934bf2 -->|calls| 48bc61b1_05ca_3121_50a7_2f02cdcf2f03
  style 14d92bc1_ead1_09a4_f147_3d6283934bf2 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