-
Notifications
You must be signed in to change notification settings - Fork 32
Typescript is not recognized well #597
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
Comments
I tried making a minimal reproduction and this seems to work for me (no type errors).
I'm using file modules in the playground to replicate your environment, It is important to note you can't do |
Would you be able to provide a reproduction? 🙏 |
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
Seems like this problem is also plaguing the most recent NuxtUI 3.1.0 release, see nuxt/ui#3973 for the corresponding NuxtUI issue and this code sandbox as a reproduction https://codesandbox.io/p/devbox/flamboyant-scott-k7p4kv. In the sandbox I try to import the In a previous version of NuxtUI build with |
Whoops. Mind giving it a second try? Was still on private by default. |
Here is another Stackblitz reproduction with the same setup: Nuxt starter Stackblitz + NuxtUI built with |
Can you reproduce without Nuxt UI? (The issue might be to do with nuxt/ui rather than the module builder.) |
@hanneskuettner @benjamincanac looks like there's an issue with pkg-pr-new generated files (or, if this is the only version with the latest module-builder, an issue with the build config or module builder): e.g. https://pkg.pr.new/@nuxt/ui@df83ab3 has this in import template from "/home/runner/work/ui/ui/src/theme/textarea"
const buttonGroup = [
"horizontal",
"vertical"
] as const this is unresolvable of course (cc: @benjamincanac) however, resolving that issue we still have somewhat of a problem - seems like Vue can't resolve types exported from SFCs. Here's a reproduction with just Vue + Nuxt: I'll need to see if we can reproduce with Vite + Vue (without Nuxt). |
@danielroe This was a bug introduced in |
update: this is reproducible without Nuxt https://stackblitz.com/edit/github-ja4alwiy question: is this a bug in (I wasn't able to get this to work with |
Don't know if this is somewhat redundant with what you reported @danielroe, but it looks like attempting the same thing with the vite |
I've just noticed this issue, and while debugging stuff around with vue-tsc the problem is indeed with The only way I've managed it to make it work is by changing -export * from './Component.vue';
+export * from './Component.d.vue.mts'; which I don't really like, since typescript's tagging @cjpearson and @Teages to inform on the topic EDIT: vue-tsc typechecking does work, so this might be possible by fixing only mkdist itself |
I think it is more like a upstream bug, typescript with I will try to make a reproduce with |
Check my stackblitz from above. Afaict this is a reproduction with just https://stackblitz.com/edit/vitejs-vite-gq1pwszz It has both the |
I think it is a reproduction with I want to check what happened when vue resolving the type with |
Oh sorry! I misunderstood you there. This is obviously using You can just see it failing with an error from within |
I think we need to update in helpful info from @brc-dd, who writes: I can only get this to work
// dts
export { default as Component } from './Component.vue.js'
export type * from './Component.vue.d.ts'
// js
export { default as Component } from './Component.vue'
// dts
export { default as Component } from './Component.vue'
export type * from './Component.vue' // maybe not needed? since if it was using lang="ts"
// you would've extracted types to dts
// js
export { default as Component } from './Component.vue' tried other combinations, but they don't appear to be working |
Vue only loads the original @vue/compiler-sfc: src/script/resolveType.ts#L1154 I think it would be better to make a patch on vue (don't use original I'm now starting to wonder if I misunderstood |
Noticed the upstream merge and was checking out Typescript still complains for |
Yes, I'm currently considering solutions. Previously Vue provided type support for .vue files by making TypeScript recognize the existence of .vue.ts files through configuration workarounds. I'm concerned that this change might force users to choose between the new Maybe we can generate both. |
Uh oh!
There was an error while loading. Please reload this page.
I updated to version 1.0.1 and I'm having a problem recognizing the typescript structure of the components.
For example now in my project in the file: ".nuxt/components.d.ts"
there is a component of the module that I made but it tells me any.
Instead I have another library (also made by me) and it recognizes very well and I have not updated module-builder.
UPDATED
If I specify .d.ts in the ".nuxt/components.d.ts" file instead, it works.
Current settings package.json:
The text was updated successfully, but these errors were encountered: