framework icon indicating copy to clipboard operation
framework copied to clipboard

`nuxi prepare` yields incorrect type definitions in target folder's `.nuxt`

Open Voltra opened this issue 3 years ago • 0 comments

Environment

  • Operating System: Windows_NT
  • Node Version: v16.14.0
  • Nuxt Version: 3.0.0-rc.12
  • Nitro Version: 0.6.0
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

  1. Clone this branch of my PR fork of nuxt-session
  2. Open src/types.ts
  3. Notice that SessionOptions#ipPinning has the type SessionIpPinningOptions|boolean
  4. Notice that ModuleOptions#session has the type Partial<SessionOptions>
  5. Notice that FilledModuleOptions is ModuleOptions where no member is Partial
  6. Notice that ModuleRuntimeConfig#session has the type FilledModuleOptions
  7. Open src/module.ts
  8. Notice everything from src/types.ts is exported there (results is the same if types are declared directly in src/module.ts)
  9. Run npm run dev:prepare
  10. Open playground/.nuxt/types/schema.d.ts
  11. Notice that RuntimeConfig#session.session.ipPinning has type boolean

Describe the bug

Types generated by nuxi prepare seem to be inferred from the default values even when interfaces are properly provided and exported as well as properly picked up by nuxt-module-build --stub.

Types generated by nuxi prepare should use the provided interfaces when present, and only rely on inference when absent.

Additional context

No response

Logs

No response

Voltra avatar Nov 05 '22 13:11 Voltra