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 type declaration is not working as expected for Boolean props #4783

Closed
phucnguyen035 opened this issue Oct 11, 2021 · 5 comments · Fixed by #4790
Closed

Prop type declaration is not working as expected for Boolean props #4783

phucnguyen035 opened this issue Oct 11, 2021 · 5 comments · Fixed by #4790

Comments

@phucnguyen035
Copy link

phucnguyen035 commented Oct 11, 2021

Version

3.2.20

Reproduction link

github.com

Steps to reproduce

  1. Clone repo and install dependencies
  2. Run npm run build
  3. Run npm run serve
  4. Browse to http://localhost:5000

What is expected?

With type definition in production build, bool prop should have value true when passed in with no value (as documented here)

What is actually happening?

With type definition in production build, bool prop has value "" (empty string) when passed in with no value


This issue only happens in production build: bool prop is evaluated as empty string when passed in with no value. In development envrionment, bool prop is properly recognized as a boolean prop.

When inspecting production build, bool property in props has null value.
image

When refactoring from type declaration to runtime declaration, it works normally. In production build, bool property in props has type of Boolean
image

@LinusBorg
Copy link
Member

It would be helpful if the repro provided your actually demonstrate the issue.

@phucnguyen035
Copy link
Author

My bad, I have updated with link to repository, as well as revising description

@paraboul
Copy link
Contributor

paraboul commented Oct 12, 2021

Same issue here. Looks like a regression in production build. This broke us just recently (all our boolean props values suddenly evaluate to false).

edit: @LinusBorg I confirm, this is a regression in 3.2.20. I'd mark this as important 🙏

@soulsam480
Copy link

Any updates on the related PR getting merged ?

@languanghao
Copy link

languanghao commented Oct 24, 2021

Not work, get open = ''

withDefaults(defineProps<{
   open?: bool
}>(), {
  open: false,
})

Work fine, get open=false

defineProps({
   open: {
      type: Boolean,
      default: false,
   }
})

Both of these codes works fine in v3.2.19

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

Successfully merging a pull request may close this issue.

5 participants