-
-
Notifications
You must be signed in to change notification settings - Fork 392
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
Comments
This was referenced Feb 4, 2022
For me I think the message is enough, but if you have an idea to improve the message PR is very welcome: https://github.com/johnsoncodehk/volar/blob/4e20cfbb354671c4621d5bebeded2cbd3b430703/vue-language-tools/vue-language-service/src/plugins/vue.ts#L156 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).
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.
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?
The text was updated successfully, but these errors were encountered: