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

dx(runtime-core): warn when the prop type is [] #7608

Merged
merged 3 commits into from
Nov 10, 2023

Conversation

skirtles-code
Copy link
Contributor

@skirtles-code skirtles-code commented Jan 31, 2023

A common mistake when declaring props is to use type: [] instead of type: Array. The mistake leads to a somewhat cryptic warning message:

Invalid prop: type check failed for prop "apple". Expected , got Array

SFC Playground

This PR introduces special handling for the empty array, so that it yields a more specific warning:

Prop type [] for prop "apple" won't match anything. Did you mean to use type Array instead?

Example

In theory it is possible to perform this check much sooner, rather than waiting for prop validation to fail, but I didn't think it was worth the extra complexity.

@pikax pikax added the ready to merge The PR is ready to be merged. label Oct 20, 2023
@yyx990803 yyx990803 merged commit a5491e1 into vuejs:main Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged.
Projects
Development

Successfully merging this pull request may close these issues.

4 participants