nuxt-open-fetch
nuxt-open-fetch copied to clipboard
Cannot find module '#open-fetch-schemas/..."
Environment
Nuxt 4
Reproduction
Start a project with nuxt-open-fetch 0.9.1 and start it with npm run dev npm update to get to version 0.9.2 and start again
Describe the bug
inside .nuxt\open-fetch.ts the import type { paths as ... throws the following error inside the IDE Cannot find module '#open-fetch-schemas/***' or its corresponding type declarations.
but it works in 0.9.1 not in 0.9.2
Additional context
you need to run "npm run dev" after changing from 0.9.1 to 0.9.2 to see the error inside .nuxt\open-fetch.ts
Logs
No response
For now I am using
"devDependencies": { "nuxt-open-fetch": "0.9.1",...
not 0.9.2 to have a working project in my IDE. Cause otherwise all the endpoints have an any type
@schillerenrico are you still able to reproduce it?
I run into this issue as well.
It's odd, since the generated ./nuxt/tsconfig.json does seem to have the right entries:
"#open-fetch": [
"./open-fetch"
],
"#open-fetch-schemas/*": [
"./types/open-fetch/schemas/*"
],
The IDE (Cursor) picks it up fine, but a nuxt typecheck fails on it 🤔
On which version? 0.13 or something below?
On which version? 0.13 or something below?
On latest for me.
Could you please consider providing a reproduction? On something like stackblitz or just .zip archive?
~~Okay I think the issue is that we tried putting the openapi folder in /app, and that breaks TS.~~
~~If you keep it in the root then it seems to work.~~
Nope, still can't find the alias...
@schillerenrico are you still able to reproduce it?
I switched to nuxt open fetch x while you took a break and in the latest nuxt open fetch there is no such error for me. Using latest Nuxt Version 4, latest nuxt open fetch and this config:
nuxt.config.ts
openFetch: {
clients: {
API_FOLDER_NAME_HERE: {
baseURL: process.env.NUXT_API_URL,
schema: process.env.NUXT_API_JSON,
},
},
// needed to make plugins/fetch.ts work
disableNuxtPlugin: true,
},
package.json
"devDependencies": {
"nuxt-open-fetch": "^0.12.0",
}
tsconfig.ts
"compilerOptions": { "types": ["./schema/openapi.global.d.ts"] }
I'm generating my own schema from import type { components } from "#open-fetch-schemas/XXX"; to shorthand my types :)