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

<script setup lang="ts"> 下使用defineProps泛型定义的props时,开发时正常,打包就不正常了 #5523

Closed
7 tasks done
npmrun opened this issue Nov 3, 2021 · 1 comment

Comments

@npmrun
Copy link

npmrun commented Nov 3, 2021

Describe the bug

子组件Comp1:

<script setup lang="ts">
import { ref } from 'vue'

defineProps<{msg: string, show: boolean}>()

</script>

<template>
  <h1 v-if="show">{{ msg }}</h1>
</template>

子组件Comp2:

<script setup lang="ts">
import { ref } from 'vue'

defineProps({
  msg: String, show: Boolean
})

</script>

<template>
  <h1 v-if="show">{{ msg }}</h1>
</template>

父组件:
show 属性都是用了简写

<script setup lang="ts">
import Comp1 from './components/Comp1.vue'
import Comp2 from './components/Comp2.vue'
</script>
<template>
  <img alt="Vue logo" src="./assets/logo.png" />
  <Comp1 msg="ts泛型定义Props显示了" show />
  <Comp2 msg="js定义Props显示了" show />
</template>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

这两种方式在开发模式下时正常的,vite打包之后Comp1 不会显示,Comp2显示,是用的vite官网新建的项目测试的

Reproduction

https://github.com/npmrun/vue-ts-props

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 1.39 GB / 7.83 GB
  Binaries:
    Node: 14.15.3 - C:\Program Files\nodejs\node.EXE
    npm: 6.14.9 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.906.0), Chromium (95.0.1020.40)
    Internet Explorer: 11.0.19041.1

Used Package Manager

npm

Logs

没有报错

Validations

@sodatea
Copy link
Member

sodatea commented Nov 3, 2021

Bug in @vue/compiler-sfc.
Fixed by vuejs/core#4790

Please wait for the next patch release.

@sodatea sodatea closed this as completed Nov 3, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 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