Meituan-Dianping/mpvue · error

Invalid prop: type check failed for prop "${name}". Expected

Error message

Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(', ')}, got ${Object.prototype.toString.call(value).slice(8, -1)}.

What it means

Error "Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(', ')}, got ${Object.prototype.toString.call(value).slice(8, -1)}." thrown in Meituan-Dianping/mpvue.

Source

Thrown at src/core/util/props.js:120

  }
  if (value == null && !prop.required) {
    return
  }
  let type = prop.type
  let valid = !type || type === true
  const expectedTypes = []
  if (type) {
    if (!Array.isArray(type)) {
      type = [type]
    }
    for (let i = 0; i < type.length && !valid; i++) {
      const assertedType = assertType(value, type[i])
      expectedTypes.push(assertedType.expectedType || '')
      valid = assertedType.valid
    }
  }
  if (!valid) {
    warn(
      'Invalid prop: type check failed for prop "' + name + '".' +
      ' Expected ' + expectedTypes.map(capitalize).join(', ') +
      ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
      vm
    )
    return
  }
  const validator = prop.validator
  if (validator) {
    if (!validator(value)) {
      warn(
        'Invalid prop: custom validator check failed for prop "' + name + '".',
        vm
      )
    }
  }
}

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Pass a value matching the declared type: :count="42" (number) not count="42" (string) — remember bare attributes are always strings
  2. Fix the prop's type declaration to match what parents actually send, or widen it to an array of allowed types: type: [String, Number]
  3. Handle null/undefined boundaries: a null value skips the check only when the prop is not required, so guard optional inputs
  4. Where string/number coercion is fine, normalize inside a computed or validator
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/core/util/props.js:120 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02). Data as JSON: /api/errors/cb750255a1f15fe7. Report an issue: GitHub.