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

vue-tsc complains when exporting additional TS types from SFC #923

Closed
theoephraim opened this issue Feb 1, 2022 · 2 comments
Closed

vue-tsc complains when exporting additional TS types from SFC #923

theoephraim opened this issue Feb 1, 2022 · 2 comments

Comments

@theoephraim
Copy link

In version 0.29.8, I was able to export additional types from my SFCs without any issues, while in version 0.31.1, everything works fine in VSCode, but when I run vue-tsc, I get errors like the following:

Module '"@/common/components/general/Icon/Icon.vue"' has no exported member 'IconNames'. Did you mean to use 'import IconNames from "@/common/components/general/Icon/Icon.vue"' instead?

(I'm not positive about the versions in between)

To clarify, in my component Icon.vue, I may be exporting additional types to use in other components. For example:

export type IconNames = 'arrow' | 'check' | 'x' | ...;
...
const props = defineProps({
  name: { type: String as PropType<IconNames>, required: true },
  ...
});
...
@theoephraim
Copy link
Author

theoephraim commented Feb 3, 2022

Moving extra named type exports to an additional <script> tag alongside the <script setup> tag does the trick, and I believe is the intended behaviour - see docs although more specific info about TS types should be added.

This was just extra confusing because it used to work but changed suddenly.

(UPDATE - I made change to Vue docs and it's now more clear)

@theoephraim
Copy link
Author

theoephraim commented Feb 4, 2022

Closing this to open a new issue for the follow up suggestion

volar should show more helpful errors in this situtation, telling the user to move any extra named exports (whether types or otherwise) to a separate script block - rather than saying they should be moved to the top.

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

1 participant