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

After 0.31.1, problems caused by type having to be placed in the head #943

Closed
lykl opened this issue Feb 7, 2022 · 4 comments
Closed

After 0.31.1, problems caused by type having to be placed in the head #943

lykl opened this issue Feb 7, 2022 · 4 comments
Labels
question Further information is requested

Comments

@lykl
Copy link

lykl commented Feb 7, 2022

As I mentioned in #901, although the editor no longer reported an error at that time, I did not test the packaging, now I test the packaging and found the packaging error, the problem is the same as the last issue, I used vite + vue-tsc.
Attach an error log:

src/components/roleModal.vue:168:21 - error TS2339: Property 'changeLoading' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{ width: string; title: string; modelValue: 
boolean; asyncClose: boolean; showBtn: boolean; destroyOnClose: boolean; }> & Omit<...>; ... 10 more ...; $watch(source: string | Function, cb: Function, options?: WatchOptions<...> | undefined): WatchStopHandle; }...'.

168     modalRef.value?.changeLoading(false)
@lykl
Copy link
Author

lykl commented Feb 7, 2022

Eventually, I had to re-type the function in the corresponding file.

<script lang="ts">
export interface ModalExpose {
  changeLoading: (loading: boolean) => void
}
</script>
<script lang="ts" setup>
...
<script>

I'm not sure there's a better way.

@theoephraim
Copy link

theoephraim commented Feb 7, 2022

From what I can tell, while this did change recently in vue-tsc, I believe it is intentional with the current script setup design. Any additional named exports are supposed to be in an additional <script> tag, so it makes sense that type-only exports would be included in that rule.

See related issues:

I just added some changes to the vue 3 docs that explicitly call this out, although I'd love some more confirmation from the vue core team that this is correct and desired going forward.

Not really so bad once you know... Although automatically hoisting things and just working would definitely be better. It also still leaves some weird edge cases where you need things exported that involve other things that are not, but need to be available in the template. 🤷

@lykl
Copy link
Author

lykl commented Feb 8, 2022

From what I can tell, while this did change recently in vue-tsc, I believe it is intentional with the current script setup design. Any additional named exports are supposed to be in an additional <script> tag, so it makes sense that type-only exports would be included in that rule.

See related issues:

I just added some changes to the vue 3 docs that explicitly call this out, although I'd love some more confirmation from the vue core team that this is correct and desired going forward.

Not really so bad once you know... Although automatically hoisting things and just working would definitely be better. It also still leaves some weird edge cases where you need things exported that involve other things that are not, but need to be available in the template. 🤷

Thanks for your reply.
The current problem is that the verification rules for volar and vue-tsc are inconsistent, which is certain.
However, I may have to accept that typeof cannot be used by export.

@lykl lykl closed this as completed Feb 8, 2022
@johnsoncodehk
Copy link
Member

@lykl see vuejs/core#4397 (comment).

@johnsoncodehk johnsoncodehk added the question Further information is requested label Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants