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

Typescript not picking up extended NuxtConfig interface when installing with pnpm #26921

Open
arnestaphorsius opened this issue Apr 24, 2024 · 3 comments

Comments

@arnestaphorsius
Copy link

Environment


  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: -
  • Package Manager: pnpm@8.15.3
  • Builder: -
  • User Config: devtools, modules, ui, colorMode
  • Runtime Modules: @nuxt/ui@2.15.2
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-yurofm?file=package.json,nuxt.config.ts

Describe the bug

When using a module, for example @nuxt/ui, and installing dependencies with pnpm, the extended type for NuxtConfig is not being picked up by Typescript (both tsc and vue-tsc). This leads to a type error in nuxt.config.ts:

nuxt.config.ts:5:3 - error TS2353: Object literal may only specify known properties, and 'ui' does not exist in type 'InputConfig<NuxtConfig, ConfigLayerMeta>'.

5   ui: {
    ~~

Found 1 error in nuxt.config.ts:5

Additionally, I found that:

  • the extended interface is present in .nuxt/schema.d.ts
  • removing node_modules and reinstalling with npm will fix the error
  • type casting the input parameter of defineNuxtConfig as InputConfig<NuxtConfig> will circumvent the issue, but requires me to add c12 as a dependency

Additional context

This is my first project using pnpm, but I decided to give it a go after I saw nuxt itself uses it. Because of that I was also surprised I did not find any other issues mentioning this. So perhaps this is a misconfiguration on my end, and people here know the answer straight away. But I decided to open a bug since I could easily reproduce the issue with Stackblitz.

Logs

No response

Copy link

stackblitz bot commented Apr 24, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@huang-julien
Copy link
Member

hi 👋 can you try with a --shamefully-hoist install ?

@arnestaphorsius
Copy link
Author

Hi @huang-julien! When I install with --shamefully-hoist it types correctly, so I reckon the error is in the node_modules struture of pnpm.

Any clue on why this happens? If I have to use that flag I probably just switch back to npm. Not really a problem, but I wonder if there's something to be fixed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants