oscklm
oscklm•2mo ago

Issue with convex being picked up by `npx tsc` in expo project

Hello, was hoping some typescript wizard could help me out here. I've been trying to configure my repos tsconfig to not clash with the tsconfig.json in our convex/ folder. The problem Whenever i run npx tsc to check for any typescript compile errors from the root of my repo, it picks up on some files in my projects from the convex/ and says there are errors.
Found 15 errors in 6 files.

Errors Files
1 convex/activity/mutations.ts:68
2 convex/auth/CustomPassword.tsx:1
5 convex/auth/resend/PasswordResetConfig.tsx:1
5 convex/auth/resend/VerifyEmailConfig.tsx:1
1 convex/core/migrations.ts:47
1 node_modules/convex-helpers/server/zod.ts:443
Found 15 errors in 6 files.

Errors Files
1 convex/activity/mutations.ts:68
2 convex/auth/CustomPassword.tsx:1
5 convex/auth/resend/PasswordResetConfig.tsx:1
5 convex/auth/resend/VerifyEmailConfig.tsx:1
1 convex/core/migrations.ts:47
1 node_modules/convex-helpers/server/zod.ts:443
But convex/ has its own tsconfig (the default one from convex), and when running npx tsc if i cd into the convex folder, i get none of those errors as stated above. So only running tsc in the root says errors are present in a few convex folder files. I'm using this tsconfig, since im in a expo project:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex/**/*"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex/**/*"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
I've tried a few things: - Removed the "**/*.tsx", "**/*.ts" from the include, as i thought maybe those were overwriting the exclude i added, but that messed all my path imports up in my project. - Playing around with multiple different glob patterns for the excludes, but without luck - Tried setting up a reference in the root tsconfig to the one in convex/ but that didn't work out due to "noEmit": true in the convex tsconfig
15 Replies
Convex Bot
Convex Bot•2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
FleetAdmiralJakob 🗕 🗗 🗙
Could you try replacing convex/**/* with convex
oscklm
oscklmOP•2mo ago
unfortunately I've already tried all possible glob patterns there is, this doesn't affect anything in my case.
FleetAdmiralJakob 🗕 🗗 🗙
Maybe the -p tag helps:
"scripts": {
"tsc:root": "tsc -p tsconfig.json",
"tsc:convex": "tsc -p convex/tsconfig.json"
}
"scripts": {
"tsc:root": "tsc -p tsconfig.json",
"tsc:convex": "tsc -p convex/tsconfig.json"
}
oscklm
oscklmOP•2mo ago
No luck with -p either, problem still persists.
FleetAdmiralJakob 🗕 🗗 🗙
Mhmm, this one is weird Sure you havent cached anything through turborepo or similar?
oscklm
oscklmOP•2mo ago
not a mono repo, and not using turborepo either
oscklm
oscklmOP•2mo ago
ty though
FleetAdmiralJakob 🗕 🗗 🗙
For me it just doesnt make sense why it doesnt exclude the convex dir. Could you delete the tsconfig inside the convex dir and try again, just for testing purposes?
oscklm
oscklmOP•2mo ago
Yeah the main thing im also wondering. But could be any of the tsconfig settings from either expo's tsconfig base file, i've tried for many hours fiddiling with removing certain settings 1 by 1, but without any luck of getting closer to figuring out whats happening: Deleting the tsconfig in the convex folder doesn't change the result of running the npx tsc -p . or any other variant of the npx tsc cmd
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Expo",

"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
"jsx": "react-native",
"lib": ["DOM", "ESNext"],
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "ESNext"
},

"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Expo",

"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
"jsx": "react-native",
"lib": ["DOM", "ESNext"],
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "ESNext"
},

"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}
Or from my root:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
Okay, just got something to change the outcome a bit. Which seems to no longer result in tsc errors coming from the convex/ directory: I went and imported the tsconfig settings from the expo base tsconfig into my own and commented out this specific setting esModuleInterop:
{
// "extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"allowJs": true,
// "esModuleInterop": true,
"jsx": "react-native",
"lib": ["DOM", "ESNext"],
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "ESNext",
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
{
// "extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"allowJs": true,
// "esModuleInterop": true,
"jsx": "react-native",
"lib": ["DOM", "ESNext"],
"moduleResolution": "node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "ESNext",
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
Now my npx tsc doesnt error or pick up anything from the /convex directories, yet it now errors about 232 other issues with my project now 🫠 so sadly wont do as a fix leavin this info here in case that gives food for though for anything more experienced with tsconfigs
erquhart
erquhart•2mo ago
Here's my expo project's working root tsconfig, in case it helps:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"],
"@cvx/*": ["./convex/*"],
"~/*": ["./*"]
},
"lib": ["ES2023"],
"moduleResolution": "Bundler",
"noImplicitAny": true,
"useUnknownInCatchVariables": false,
"noUnusedLocals": false,
"noUncheckedIndexedAccess": true,
"strict": true,
"noErrorTruncation": true
},
"exclude": ["share/**"]
}
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"],
"@cvx/*": ["./convex/*"],
"~/*": ["./*"]
},
"lib": ["ES2023"],
"moduleResolution": "Bundler",
"noImplicitAny": true,
"useUnknownInCatchVariables": false,
"noUnusedLocals": false,
"noUncheckedIndexedAccess": true,
"strict": true,
"noErrorTruncation": true
},
"exclude": ["share/**"]
}
deen
deen•5w ago
Does your convex tsconfig have its own paths config? If so, your main typescript likely doesn't understand how to resolve those paths. Anything you import into your project has to be parsed relative to its tsconfig - the imported modules, everything they import, etc. - it doesn't care about your convex specific config. Exclude does nothing in this situation, importing from the directory overrides this: https://www.typescriptlang.org/tsconfig/#exclude You can use paths in each project - but they have to be valid from any involved tsconfig's relative position in the structure.
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
deen
deen•5w ago
If it's somehow not that, seeing your convex tsconfig and the full error messages would be helpful.
ampp
ampp•5w ago
I've had a lot of these types of issues, and part due to mono-repo, i think rule number 1 is to always have convex running that way you can figure it out the second it starts happening. - Id comb over all imports going to your convex folder. Classes seemed to always cause it easier then anything else. Worst case you generate a api and point all api calls to it, and switch Id -> Generic Id And then you have zero references to convex After our last issue i no longer have a single import to anything but _generated

Did you find this page helpful?