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

@vitejs/plugin-vue boolean props with no value have wrong type with --mode production and script setup #5612

Closed
7 tasks done
hanneskuettner opened this issue Nov 10, 2021 · 2 comments

Comments

@hanneskuettner
Copy link

Describe the bug

When creating a component with the script setup syntax and a boolean prop and accessing the prop results in different (and wrong) types when running vite --mode production vs vite.

<!-- MyComponent.vue -->
<script setup lang="ts">
    const props = defineProps<{ bool: boolean }>();
    
    console.log(typeof props.bool)
</script>

<!-- App.vue -->
<template>
    <MyComponent :bool="true" />
    <MyComponent bool /> 
    <MyComponent />  
</template>

This results in the following output using vite

boolean
boolean
boolean

and using vite --mode production

boolean
string
undefined

I have verified (see reproduction) that it's only the case for components using the script setup syntax and not the normal script tags.

Reproduction

https://stackblitz.com/edit/vitejs-vite-2ehfh6

Running vite --mode production and vite results in different output.

System Info

System:
    OS: Linux undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: Unknown - /bin/jsh
  Binaries:
    Node: 14.16.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm
  npmPackages:
    @vitejs/plugin-vue: ^1.9.4 => 1.9.4 
    vite: ^2.6.13 => 2.6.14

Used Package Manager

npm

Logs

No response

Validations

@grunghi
Copy link

grunghi commented Nov 15, 2021

Just stumbled upon this issue and it was apparently resolved in the new release of vue 3, see vuejs/core#4783

@hanneskuettner
Copy link
Author

Oh, so it was a vue-next and not a vite problem. Sorry about that, I thought I checked thoroughly enough.

Marking this as closed then, thanks for pointing me to specific issue!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants