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

Property validator should report the property that failed type / validator check #12454

Open
velis74 opened this issue Feb 2, 2022 · 0 comments · May be fixed by #12455
Open

Property validator should report the property that failed type / validator check #12454

velis74 opened this issue Feb 2, 2022 · 0 comments · May be fixed by #12455
Labels
contribution welcome improvement warnings related to development warnings

Comments

@velis74
Copy link

velis74 commented Feb 2, 2022

What problem does this feature solve?

Components with multiple properties might fail property validation at the most inopportune time: assigning one property will trigger property validation for all function initProps (vm, propsOptions). Stack trace will show that the issue was triggered by assigning a specific property "prop1" while validation will actually fail on "prop2". If this is combined with component actually rendering for the first time ("prop1" was the trigger), it will be unclear what property actually failed.

In my case, reported error message was:

[Vue warn]: Invalid prop type: "[object Object]" is not a constructor

This is from method function assertType (value, type, vm)

Clarify for the actual n00b error message I received: I specified prop type to be of an "enum" class declared with Object.freeze. Actual values are, naturally, Number.

What does the proposed API look like?

It would be clearer to add prop name to the message like this:

[Vue warn]: Invalid prop "propName" type: "[object Object]" is not a constructor

This would require to add propName (or just name) parameter to assertType in order to be able to include it in the message

@posva posva added contribution welcome improvement warnings related to development warnings labels Feb 2, 2022
espresso added a commit to espresso/vue that referenced this issue Feb 3, 2022
…e" warning

Previously, the "Invalid prop type" warning message returned by the property validator did not
include the name of the offending property. In certain scenarios this obscurity can make it
difficult to identify the source of the issue. To address this, I have added the name of the
offending property to the output as suggested in vuejs#12454.

fix vuejs#12454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome improvement warnings related to development warnings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants