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

Components dont have default export with multiple <script> #4423

Open
Nisgrak opened this issue Aug 23, 2021 · 14 comments · Fixed by #4522
Open

Components dont have default export with multiple <script> #4423

Nisgrak opened this issue Aug 23, 2021 · 14 comments · Fixed by #4522

Comments

@Nisgrak
Copy link

Nisgrak commented Aug 23, 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>

@posva
Copy link
Member

posva commented Aug 23, 2021

Maybe a duplicate of #4294 as it seems that you can import what is exported in other files

@Nisgrak
Copy link
Author

Nisgrak commented Aug 24, 2021

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

@Nisgrak
Copy link
Author

Nisgrak commented Aug 24, 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!

@Nisgrak
Copy link
Author

Nisgrak commented Aug 25, 2021

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

@Bigfish8
Copy link
Contributor

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

@Nisgrak
Copy link
Author

Nisgrak commented Aug 26, 2021

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

@Bigfish8
Copy link
Contributor

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

@henribru
Copy link

henribru commented Sep 6, 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.

@edison1105
Copy link
Member

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

@henribru
Copy link

henribru commented Sep 6, 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

@edison1105
Copy link
Member

edison1105 commented Sep 6, 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.

@edison1105 edison1105 reopened this Sep 6, 2021
@ygj6
Copy link
Member

ygj6 commented Sep 7, 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';

@so1ve
Copy link
Member

so1ve commented Sep 2, 2023

Still an issue? 🤔

@Kadeluxe
Copy link

Kadeluxe commented Jan 9, 2024

Yes, still not resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants