Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
shurfee opened this issue Dec 19, 2018 · 13 comments · Fixed by #9241
Closed

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

shurfee opened this issue Dec 19, 2018 · 13 comments · Fixed by #9241
Labels

Comments

@shurfee
Copy link

shurfee commented Dec 19, 2018

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)"
@posva posva changed the title Error handling improvement for prop types Warn when the type of a prop isn't a constructor Dec 19, 2018
@cedric05
Copy link

can i work on this?

@posva
Copy link
Member

posva commented Dec 19, 2018

Yes :)

@cedric05
Copy link

raised #9227

@Zarad1993
Copy link
Contributor

Zarad1993 commented Dec 22, 2018

HI guys, I'm very interested with this project and I wanted to get started with a simple issue. @cedric05 takes the priority but I'd appreciate a review #9241 @posva . Thank you so much.

@posva posva added warnings related to development warnings has PR labels Dec 22, 2018
@JonathanDn
Copy link

Hey @posva I would love to aid with any good first issues in the future if needed :)

@Zarad1993
Copy link
Contributor

@posva - Is there any chance #9241 can be considered a candidate PR for this issue?

@posva
Copy link
Member

posva commented Jan 14, 2019

Yeah, it contains tests and looks better overall but I haven't checked it yet 🙂

@Zarad1993
Copy link
Contributor

Gotcha, I'll keep my eye out there if it needs any modifications.

@huruji
Copy link

huruji commented Mar 7, 2019

I had this error just now. how to fix?

@posva
Copy link
Member

posva commented Mar 7, 2019

Use a constructor like Number, String, Function, etc.
Remember you can and should use the forum or the Discord chat to ask quick questions!

@AlekNiebla
Copy link

AlekNiebla commented Apr 20, 2019

hey can I work on this first time issue? im new at working on Opensource projects and I would love to give it a try starting with this issue

@Holgermueller
Copy link

Would it be okay for me to work on this issue?

@TobiTenno
Copy link

TobiTenno commented Mar 5, 2023

the "solution" doesn't help much with... Invalid prop type: "[object Object]" is not a constructor. Earlier recommendations of specifying the prop that errored would have been very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants