Typecheck errors from extended app

I have main app which include:
/app/repository/base.repo.ts <- fetchGet, fetchPost etc
/app/repository/base.repo.ts <- fetchGet, fetchPost etc
No I import it in my repositories
import BaseRepo from "~/repository/base.repo";
import BaseRepo from "~/repository/base.repo";
When I run npx nuxi typecheck everything is okey. But I have app2 which extends main app.
extends: [["@app/main", { install: true }]],
extends: [["@app/main", { install: true }]],
and when i run typecheck here:
error TS2307: Cannot find module '~/repository/base.repo' or its corresponding type declarations.
error TS2307: Cannot find module '~/repository/base.repo' or its corresponding type declarations.
How can I handle it?
2 Replies
kapa.ai
kapa.ai2d ago
Hi @UnSpiraTive. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- This issue is similar to a known limitation with Nuxt's type resolution when using Layers or extending apps. When you run type checking in the extended app (app2), TypeScript cannot resolve the ~ alias to files in the parent layer (main app), resulting in errors like:
error TS2307: Cannot find module '~/repository/base.repo' or its corresponding type declarations.
error TS2307: Cannot find module '~/repository/base.repo' or its corresponding type declarations.
This is because the auto-generated .nuxt/tsconfig.json in the extended app does not automatically include the source directories from the parent layer for alias resolution. A similar problem is described in a GitHub issue, where type augmentations and imports from a Layer are not picked up by the extending app during type checking, even though they work in the Layer itself. The root cause is that the type references and paths from the Layer are not merged into the extending app's type system during type checking, leading to missing module errors Type augmentation inside a remote Layer are not resolved inside an App. Workarounds and Recommendations: - There is no official solution documented in the knowledge sources for automatically merging type paths from parent layers into the extending app's type system. - As a workaround, you may try to manually extend the tsconfig.json in your extended app to include the relevant paths from the parent layer, but this is not officially documented and may not be robust. - This is a known limitation, and if you need a robust solution, consider raising an issue or feature request with the Nuxt team. Summary:
Currently, the knowledge sources do not provide an official or fully supported way to resolve this type-checking issue when using Layers and the ~ alias in extended Nuxt apps. The problem is recognized in the community, but a built-in solution is not documented at this time. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2d ago
<@497437240503435285> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?