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

bug: Issues building when using vue with typescript #332

Closed
1 task done
CodeDelegates opened this issue Jan 6, 2025 · 17 comments · Fixed by #333 or #335
Closed
1 task done

bug: Issues building when using vue with typescript #332

CodeDelegates opened this issue Jan 6, 2025 · 17 comments · Fixed by #333 or #335
Labels
bug Something isn't working

Comments

@CodeDelegates
Copy link

Describe the issue

When Vue imports type from another file. npm run build:registry fails.
image

Registry Link

https://github.com/CodeDelegates/JS-repo-vue-TS

Reproduction Link

https://github.com/CodeDelegates/JS-repo-vue-TS

Steps to reproduce

To reproduce error:

Repo:

https://github.com/CodeDelegates/JS-repo-vue-TS

npm install
npm run build:registry

or outside of reproduction repo: ### Minimal code to replicate

image
Test.vue

<script setup lang="ts">
	import type { PropType } from './type';

	const props = defineProps<PropType>();
</script>
<template>
	<div>
		{{ value }}
	</div>
</template>

type.ts

export type PropType = { value: string };

It works when PropType is defined directly in Test.vue file, but fails when imported from another file.

Validations

  • I have checked other issues to see if my issue was already reported or addressed
@CodeDelegates CodeDelegates added the bug Something isn't working label Jan 6, 2025
@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

Ah this is an easy fix sorry about that!

Working on a PR now!

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

Fixed in v1.23.6

@CodeDelegates
Copy link
Author

I´m actually impressed by speed of your fix. Awesome.
Tried it. Fix works,

But found error "one level" deeper.
When trying to import type definition from external library (module import).

image

Writing it here as commnent so i don´t spam issues. But i can create new issue with code to replicate it?

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

vue is so special :)

I don't think you need to create another issue I think I can reproduce from that error!

@ieedan ieedan reopened this Jan 6, 2025
@ieedan ieedan changed the title bug: build:registry in vue3 not working with Typescript and types imported from another file bug: Issues building when using vue with typescript Jan 6, 2025
@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

Hopefully we can work together a bit on this one I am not personally a Vue user so you may have been the first to really test it!

@CodeDelegates
Copy link
Author

Sure, will test it.

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

I am not sure this can be solved from my end...

Can you try adding the following to your package.json:

"peerDependencies": {
	"typescript": "^5.0.0"
},

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

Do you normally have to use typescript as a peer dependency when using vue?

@CodeDelegates
Copy link
Author

CodeDelegates commented Jan 6, 2025

it is added on my end, and yes its normally a peer dependency:

currently:
"peerDependencies": {
"typescript": "^5.7.2",
},

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

it was already added? Or you just added it now?

@CodeDelegates
Copy link
Author

It was. (so it wasnt problem)

@CodeDelegates
Copy link
Author

It might be problem in @vue/compiler-sfc as same "error" appears on some issues for jest (test library)

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

Can you link the issue

@CodeDelegates
Copy link
Author

vuejs/core#8301

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

Thanks!

I have run out of time to look at this at the moment I should be able to find some more later this afternoon!

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

So...

Rather frustratingly there seems to be a difference between @vue/compiler-sfc and vue/compiler-sfc. If I use vue/compiler-sfc both of the previously mentioned issues just go away.

This is unfortunate since the vue package is roughly 1mb larger than @vue/compiler-sfc but hopefully tsup can help me out with that a bit.

So I am going to just use vue/compiler-sfc and that should clear this up. Working on a PR now!

@ieedan
Copy link
Owner

ieedan commented Jan 6, 2025

Just merged a fix you do need to have typescript installed for the vue compiler to work though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants