Subscribe on changes!

Components dont have default export with multiple <script>

avatar
Aug 23rd 2021

Version

3.2.4

Reproduction link

https://github.com/Nisgrak/test-setup-ts

Steps to reproduce

  1. Init the proyect with yarn serve
  2. See the error that happen with HelloWorld components

What is expected?

Can export interfaces and other vars in a normal <script> tag having an <script setup> one

What is actually happening?

An error with the default export of the HelloWorld component


I try to create a interface of the props of a components and export it, using the new <script setup>, but it don't work and in the docs it says if have to export something must be in a normal <script>

avatar
Aug 23rd 2021

Maybe a duplicate of https://github.com/vuejs/vue-next/issues/4294 as it seems that you can import what is exported in other files

avatar
Aug 24th 2021

It give another error, I create a branch for the example, moving the export in the <script setup> tag image

avatar
Aug 24th 2021

It seems if I add this to the bottom of the <script> tag works, but cant use the interface to declare the prosp inside <script setup>, it's need to exist inside the setup, but there can't be exported, strange...

export default defineComponent({});

I created the branch workaround in the repo with this fix If you need to test it, thanks!

avatar
Aug 25th 2021

@posva I try with the new version 3.2.6 but stay the same

avatar
Aug 26th 2021

It seems caused by IDE plugin.Vetur doesn't support it now, you can try Volar instead.

avatar
Aug 26th 2021

I use Volar @Bigfish8. How an IDE plugin can affect the compilation of Vue?

avatar
Aug 26th 2021

Sorry, I was misleaded by the picture.It is indeed a compilation bug.

avatar
Sep 6th 2021

I'm still having this issue in 3.2.9. I've been using the workaround Nisgrak and if I remove it in 3.2.9 the errors about SFCs not having a default export come back.

avatar
Sep 6th 2021

@henribru you should update @vue/compiler-sfc to '3.2.9'

avatar
Sep 6th 2021

@edison1105 I did update both dependencies, actually.

If Nisgrak's repo no longer reproduces the issue I can attempt to make another one later today

avatar
Sep 6th 2021

@henribru yes, It still has the issue. It's my fault. My PR has not fixed this issue but improve the defineProps. I misunderstood it. This is about using the exported interface in another file.

the error info is changed. image

works fine in playground, it's not a vue core bug.

avatar
Sep 7th 2021

It works fine in vite project, or ignores the type check can also work normally.

// @ts-ignore
import HelloWorld, { HelloWorldProps } from './components/HelloWorld.vue';
avatar
Sep 2nd 2023

Still an issue? 🤔

avatar
Jan 9th 2024

Yes, still not resolved.