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

Show more helpful error when trying to export from script setup #940

Closed
theoephraim opened this issue Feb 4, 2022 · 1 comment
Closed

Comments

@theoephraim
Copy link

According to the vue docs, additional named exports SFCs using script setup should be placed in a separate script block alongside setup one. From the latest changes to vue, I believe this applies to type exports as well, and I have updated to the vue docs accordingly.

However volar's handling and errors are not in sync with this.

  • When exporting a const, we currently get a TS error (and a linting error if you have that set up).
    image

  • When exporting a type at the top of the file, we get no error, but vue-tsc will complain.

  • When exporting a type later in the file, we get the same TS error, plus a special warning from volar that it should be moved to the top of the file.
    image

Instead volar should give more helpful errors, warning the user if creating any additional named exports (types or not) within the script setup block, and specifically telling the user to move the export to an additional script block. Might even be able to provide a VSCode "quick fix" which moves it for you?

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

No branches or pull requests

2 participants