Skip to content

Warn when the type of a prop isn't a constructor  #9224

Closed
@shurfee

Description

@shurfee

What problem does this feature solve?

It suppose better error handling for prop types errors.
Steps to reproduce error:

  1. Set prop type equals to string ('String', not String):
exampleProp: {
  type: 'String',
}
  1. Run project and get an error:
[Vue warn]: Error in nextTick: "TypeError: Right-hand side of 'instanceof' is not an object"
TypeError: Right-hand side of 'instanceof' is not an object
    at assertType (vue.esm.js:1668)
    at assertProp (vue.esm.js:1626)
    at validateProp (vue.esm.js:1560)
    at loop (vue.esm.js:3334)
    at initProps (vue.esm.js:3367)
    at initState (vue.esm.js:3308)
    at VueComponent.Vue._init (vue.esm.js:4628)
    at new VueComponent (vue.esm.js:4798)
    at createComponentInstanceForVnode (vue.esm.js:4310)
    at init (vue.esm.js:4131)

Error log is not evident and it is difficult to understand the source of problem (first time with this error anyway).

What does the proposed API look like?

Error message in this case may look like:

"Incorrect prop type 'exampleProp' at:123 (where 123 is example string position in the code)"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions