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

import without new line at the top of setup script + defineProps causes error #4764

Closed
loogn opened this issue Oct 8, 2021 · 3 comments
Closed
Labels
has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working 🔩 p2-edge-case scope: compiler

Comments

@loogn
Copy link

loogn commented Oct 8, 2021

Version

3.2.19

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  • open the repro

What is expected?

const props = __props;
import { ref } from 'vue'

What is actually happening?

编译成的代码:
const props = __propsimport { ref } from 'vue'


第一句import那里如果不换号就会出错,vue文件会编译成 ......props=propsimport { reactive,ref} ......,应该是少一个";"
如果import那句换行的话,就不会出错了

@posva
Copy link
Member

posva commented Oct 8, 2021

There is no error

@posva posva closed this as completed Oct 8, 2021
@edison1105
Copy link
Member

<script setup>import { ref } from 'vue' // this line will cause an error
 const props=defineProps({
   foo:String
 })

const msg = ref('Hello World!')
</script>

<template>
  <h1>{{ msg }}</h1>
  <input v-model="msg">
</template>

@edison1105 edison1105 reopened this Oct 8, 2021
@posva posva changed the title 在 setup script 中使用 defineProps,导致vue文件解析错误 import without new line at the top of setup script causes error Oct 8, 2021
@posva posva added has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working labels Oct 8, 2021
@posva posva changed the title import without new line at the top of setup script causes error import without new line at the top of setup script + defineProps causes error Oct 8, 2021
@posva
Copy link
Member

posva commented Oct 8, 2021

Thanks @edison1105
It's weird the error didn't show when I opened the repro 🤔

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working 🔩 p2-edge-case scope: compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants