larsmyrup
Adding Types To Nuxt Module
@zoobzio Thanks for getting back!
We're using the nuxt-module-builder and trying to follow the pattern established by component libraries like Nuxt UI. Which seems to do the same.
However i agree that having
d.ts
-files in the runtime folder seems off and like i'm missing something 😅14 replies
Adding Types To Nuxt Module
This code:
Made my types be globally available in the consuming application, so that's great. But i'm still very open to hear any ideas for making it happen more "automatically", importing the entire directory or similar.
14 replies
Adding Types To Nuxt Module
Hi @zoobzio,
Thanks for the answer! It's very appreciated.
I've been trying using
addImportsDir
- and while it works for composables, utils etc. i can't get it to work for types. I have a types-folder and add it like:
addImportsDir(resolver.resolve('runtime/types'))
And everything seems to work in the playground. But if i publish the package with yalc (should be similar to npm, but makes testing locally a bit easier) and install it in another application i get this warning:
WARN [unimport] failed to resolve "{path}/dist/runtime/types/field-with-validation", skip scanning
Even though i can see the field-with-validation.d.ts
field in the node_modules folder of the package. Do you have any ideas?
Also when i run the playground in dev mode, types gets added to the .nuxt/imports.d.ts
-file, but when i install the module in another project, that's not the case. Even though the utils, composables etc. all are in there.
I'll try the addImportsSources
, but it seems like it's more used for adding other dependencies types, than the ones i've defined myself in the module.14 replies