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

Imports types that are not defined on build --stub #223

Open
rchl opened this issue Feb 7, 2024 · 5 comments
Open

Imports types that are not defined on build --stub #223

rchl opened this issue Feb 7, 2024 · 5 comments
Labels
question Further information is requested

Comments

@rchl
Copy link

rchl commented Feb 7, 2024

Running nuxt-module-build build --stub generates types.d.mts like:

import type { ModuleOptions, ModuleHooks, RuntimeModuleHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module'

declare module '#app' {
  interface RuntimeNuxtHooks extends RuntimeModuleHooks {}
}

declare module '@nuxt/schema' {
  interface NuxtConfig { ['sentry']?: Partial<ModuleOptions> }
  interface NuxtOptions { ['sentry']?: ModuleOptions }
  interface NuxtHooks extends ModuleHooks {}
  interface RuntimeConfig extends ModuleRuntimeConfig {}
  interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
}

declare module 'nuxt/schema' {
  interface NuxtConfig { ['sentry']?: Partial<ModuleOptions> }
  interface NuxtOptions { ['sentry']?: ModuleOptions }
  interface NuxtHooks extends ModuleHooks {}
  interface RuntimeConfig extends ModuleRuntimeConfig {}
  interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
}


export type { default } from './module'

where the "ModuleHooks, RuntimeModuleHooks, ModuleRuntimeConfig" imports are not exported from "./module".


Running nuxt-module-build build generates correct version:

import type { ModuleOptions, ModulePublicRuntimeConfig } from './module'


declare module '@nuxt/schema' {
  interface NuxtConfig { ['sentry']?: Partial<ModuleOptions> }
  interface NuxtOptions { ['sentry']?: ModuleOptions }
  interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
}

declare module 'nuxt/schema' {
  interface NuxtConfig { ['sentry']?: Partial<ModuleOptions> }
  interface NuxtOptions { ['sentry']?: ModuleOptions }
  interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
}


export type { ModuleOptions, ModulePublicRuntimeConfig, default } from './module'
@rchl
Copy link
Author

rchl commented Feb 7, 2024

With the latest version of @nuxt/module-builder this issue also triggers a warning that can't be avoided:

 WARN  RuntimeModuleHooks is a deprecated naming and will be removed in the future. Please use ModuleRuntimeHooks instead.

Note that I'm not using RuntimeModuleHooks explicitly anywhere. It's the module builder triggering it with the code it itself generates.

@YsarocK
Copy link

YsarocK commented Mar 8, 2024

Confirms too, have the error with https://github.com/YsarocK/nuxt-wp/.
Types are not well generated except when removing --stub option of dev:prepare command.

@danielroe
Copy link
Member

You can ignore the warning about RuntimeModuleHooks; it's fixed in #228.

The type files in stub mode are deliberately more expansive to contemplate all possible options you may have while developing (because it's not running continuously so it can't update the file if you add a new export).

What is the issue you are experiencing?

@danielroe danielroe added the question Further information is requested label Mar 8, 2024
@rchl
Copy link
Author

rchl commented Mar 10, 2024

I don't remember what the issue was or in which project I saw it...

I guess we can close it until some better reasoning comes up.

@rchl
Copy link
Author

rchl commented Mar 10, 2024

But then... It's not so much about which properties are generated but more about what is exported. Why would there be discrepancy in that regard? If ModuleOptions is generated in both cases then why would it only be exported in one case?

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