storyblok / storyblok-nuxt

Storyblok Nuxt module
https://www.storyblok.com/tp/nuxt-js-multilanguage-website-tutorial
MIT License
278 stars 44 forks source link

Issue: v5.0.0 - Nuxt config type errors in TS project #284

Closed oldskool73 closed 1 year ago

oldskool73 commented 1 year ago

When using version 5.0.0 in a TS based project using nuxt.config.ts, and using the 'block' type of configuration entry (i.e a separate storyblok: {...} config entry, instead of inline config under the modules), typescript shows type errors.

If using 'strict' TS checking, this will also throw errors and prevent a dev/build.

Workaround: configure via inline modules config instead.


Expected Behavior

Can configure via the storyblok configuration as normal

Current Behavior

Can not configure via the storyblok configuration as normal, throws TS errors.

Steps to Reproduce

  1. Start a Nuxt 3 TS project
  2. Install Version 5 of storyblok-nuxt
  3. Attempt to add a storyblok: {...} configuration block to nuxt.config.ts, observer type errors on dev/generate/typecheck

image

SebbeJohansson commented 1 year ago

I can confirm that the same is happening for me in 5.0.1. image

I have a feeling that it is because of the defaults in the module: https://github.com/storyblok/storyblok-nuxt/blob/main/lib/src/module.js#L15-L17

Might be time to make a "proper" ts conversion of the module.

oldskool73 commented 1 year ago

Thanks for the confirm @SebbeJohansson , agree it's probably down to the defaults (and not providing a proper/full definition of the ModuleOptions interface)

Also agree on the 'proper ts conversion' comment. The currently included module.d.ts installed with this module doesn't look correct at all ... ie it doesn't look like a normal d.ts file, it's just the module.mjs file with a different extension, and shows multiple of it's own TS errors when I open it...

image

stevengrimaldo commented 1 year ago

Any update/movement on this?

SebbeJohansson commented 1 year ago

@stevengrimaldo i took another look at this, and it looks like the module would need to be properly switched to ts so that defineNuxtModule<ModuleOptions> works. I tried to do it, but I cant get it to run. Might be above my abilities 😅

SebbeJohansson commented 1 year ago

Ive only just gone and done it. Only took like 3 hours too!

296

alvarosabu commented 1 year ago

Closed #296