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.
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:
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 tsconfig15 Replies
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!
Could you try replacing
convex/**/*
with convex
unfortunately I've already tried all possible glob patterns there is, this doesn't affect anything in my case.
Maybe the -p tag helps:
No luck with -p either, problem still persists.
Mhmm, this one is weird
Sure you havent cached anything through turborepo or similar?
not a mono repo, and not using turborepo either
Ok 😅
ty though
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?
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
Or from my root:
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
:
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 tsconfigsHere's my expo project's working root tsconfig, in case it helps:
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.
If it's somehow not that, seeing your convex tsconfig and the full error messages would be helpful.
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