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

Prop with required: false or default value should not trigger prop validation error when not provided #2141

Closed
octref opened this issue Aug 8, 2020 · 2 comments · Fixed by #2216

Comments

@octref
Copy link
Member

octref commented Aug 8, 2020

From #2135 (comment)

@octref
Copy link
Member Author

octref commented Aug 14, 2020

  • Use DiagnosticSeverity.Error for passing an undeclared prop
  • When not passing a required prop
    • If in array form, show a warning with DiagnosticSeverity.Warning (as all props are optional)
    • If in object form, only show error if required props are not passed. For example, if a component requires foo and takes an optional bar, not passing bar should not generate an error.

@yoyo930021
Copy link
Member

yoyo930021 commented Aug 14, 2020

When no component prop in template:

// case 1 -> warning
props: [foo, bar]
// case 2 -> warning
props: {
  foo: String,
  bar: String,
}
// case 3 -> error
props: {
  foo: {
    type: String,
    required: true
  }
}
// case 4 -> No any errors or warning
props: {
  foo: {
    type: String,
    required: false
  },
  bar: {
    type: String,
    default: ''
  }
}

yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Aug 31, 2020
yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Aug 31, 2020
@yoyo930021 yoyo930021 mentioned this issue Aug 31, 2020
octref added a commit that referenced this issue Sep 3, 2020
cereschen pushed a commit to cereschen/vetur that referenced this issue Sep 10, 2020
cereschen pushed a commit to cereschen/vetur that referenced this issue Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants