N
Nuxtβ€’2mo ago
ChronicStone

[TypeScript] nuxi typecheck throws errors from node_modules/@agorastore/shared-ui despite skipLibChe

Hi everyone πŸ‘‹ When running nuxi typecheck, I'm getting a bunch of TypeScript errors specifically from a Nuxt module in my node_modules (@agorastore/shared-ui). For example:
node_modules/@agorastore/shared-ui/dist/runtime/components/layout/FloatingSidebar.vue:65:16 - error TS2322: Type '{ name: "dashboard" | "auth-login"...' is not assignable to type 'RouteLocationRaw'

node_modules/@agorastore/shared-ui/dist/runtime/components/system/AppRoot.vue:38:6 - error TS2345: Argument of type '{ theme: BuiltInGlobalTheme...' is not assignable to parameter of type 'Partial<...>'
node_modules/@agorastore/shared-ui/dist/runtime/components/layout/FloatingSidebar.vue:65:16 - error TS2322: Type '{ name: "dashboard" | "auth-login"...' is not assignable to type 'RouteLocationRaw'

node_modules/@agorastore/shared-ui/dist/runtime/components/system/AppRoot.vue:38:6 - error TS2345: Argument of type '{ theme: BuiltInGlobalTheme...' is not assignable to parameter of type 'Partial<...>'
I tried adding both of these to my tsconfig.json but the errors persist:
{
"compilerOptions": {
"skipLibCheck": true
},
"exclude": [
"node_modules",
"node_modules/**/*"
]
}
{
"compilerOptions": {
"skipLibCheck": true
},
"exclude": [
"node_modules",
"node_modules/**/*"
]
}
Is there a way to make nuxi typecheck ignore modules in node_modules? I want to run type-checking on the CI before PRs can be merged, but this prevents me from doing so
5 Replies
kapa.ai
kapa.aiβ€’2mo ago
Hi @ChronicStone. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, I can offer some insights into your issue with nuxi typecheck and TypeScript errors from node_modules. The nuxi typecheck command is designed to run vue-tsc to check types throughout your app as mentioned in the Nuxt documentation (https://nuxt.com/docs/api/commands/typecheck). However, it seems that in your case, it's also checking types in the node_modules directory, which is not the intended behavior. Unfortunately, the knowledge sources don't provide a direct solution to ignore modules in node_modules during type checking. However, there are a few things you can try: 1. Ensure you're using the latest version of Nuxt and vue-tsc. There have been issues with TypeScript compatibility in the past, and newer versions might have resolved this. 2. You can try adding a server/tsconfig.json file as mentioned in the Nuxt documentation (https://nuxt.com/docs/guide/directory-structure/server#server-types):
{
"extends": "../.nuxt/tsconfig.server.json"
}

{
"extends": "../.nuxt/tsconfig.server.json"
}

While this is primarily for improving IDE type hints, it might help with type checking as well. 3. If the issue persists, you might need to create a custom TypeScript configuration for the type checking process. You could create a separate tsconfig.typecheck.json file that extends your main tsconfig.json but explicitly excludes the problematic modules:
{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"node_modules/@agorastore"
]
}

{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"node_modules/@agorastore"
]
}

Then, you could modify your typecheck script to use this configuration:
{
"scripts": {
"typecheck": "nuxi typecheck --tsconfig tsconfig.typecheck.json"
}
}

{
"scripts": {
"typecheck": "nuxi typecheck --tsconfig tsconfig.typecheck.json"
}
}

However, please note that this is a workaround and not an official solution provided in the Nuxt documentation. 4. As a last resort, you might consider using a different type checking method in your CI pipeline, such as running tsc directly on your source files, excluding node_modules. If these suggestions don't resolve your issue, you might want to consider reporting this as a potential bug to the Nuxt team, as it seems to be unexpected behavior for nuxi typecheck to check types in node_modules, especially when skipLibCheck is set to true. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.aiβ€’2mo ago
<@372104941348585473> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
ChronicStone
ChronicStoneOPβ€’2mo ago
Already tried these solutions, none worked
kapa.ai
kapa.aiβ€’2mo ago
​No Category:
help Shows this message
kapa_enable_channel Enable a channel with the given name.
kapa_enable_server Enable a server with the given name.

Type !help command for more info on a command.
You can also type !help category for more info on a category.
​No Category:
help Shows this message
kapa_enable_channel Enable a channel with the given name.
kapa_enable_server Enable a server with the given name.

Type !help command for more info on a command.
You can also type !help category for more info on a category.
ChronicStone
ChronicStoneOPβ€’2mo ago
Up, still hasn't figured out a solution to this issue ...

Did you find this page helpful?