How do I run `tsc --noEmit` for a convex project
I want to do the following
1. have source files that are not in the convex folder (since convex will report errors)
2. run the tsc --noEmit command that executes typechecks for the entire project
8 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!
What do you think won't work about this, this is fine
@conradkoh is there a place you can add a type error that is not reported when you typecheck the project at the top level? Or a place you can add a type error that is imported by something in the convex directory, that is not reported as a type error when you run npm convex dev?
generally, I just add
"include": ["./**/*", "../src/**/*"],
to the tsconfig generated by convex and the code runs fine.
however, when I run yarn @workspace/backend tsc --noEmit
, I get an error, because there is no tsconfig at the root of the project (it is in the convex folder). and of course I can add the tsconfig file to the root of the folder as well, but then I will have 2 tsconfig files for the same project.
i've never done this before (e.g. what happens if the settings for each tsconfig is different), and was just wondering if this is the recommendation.Generally you don't need to
"include"
files that you import
Is this about a monorepo issue where you're trying to typecheck across multiple projecsts? Or just a convex directory?oh interesting. maybe my bad, but i thought we need to include files that are outside of the root of the directory where tsconfig sits. not 100% sure on that.
also, it is a convex directory within the same package as other source files, in a monorepo.
the structure is
- /apps/webapp - package for remix app
- /services/backend - package for backend
the backend structure is
- /services/backed/src - source files that cannot be inside with convex due to convex trying to compile them directly
- /services/backend/convex - generated convex folder
- /services/backend/package.json
i kinda worked around it for now, by having another tsconfig at the root of the repo and haven’t really encountered any issues yet.
nope, tsc will follow imports e.g. into node_modules even if you don't include those, or "../foo.ts"
but if you want to typecheck a
utils.ts
that you never import from anywhere, as in it's dead code, then yes you need to include it from some tsconfig.json somewhere.
having anther tsconfig at the root, and just typechecking that one? that should work! Since it'll follow the imports through the convex/api.d.ts and end up checking everything that that imports.nice, i learned something, thanks a lot for this.
do you happen to know what the behavior of nested tsconfigs are? so for example if at the root tsconfig, let’s say i specify that strictNullChecks is true. then in one of the subfolders that is a child of the rootDir, i have another tsconfig where the value is false.
1. how will tsc handle this
2. how will the ide handle this, with the inferred tsconfig that should apply on each file
1. tsc will use the same tsconfig.json for everything for a given run, so it depends on which directory you run it in
2. The IDE, if it's VSCode or using that language server, will use the first tsconfig.json it finds for the file you are currently editing.
These are different, which is annoying!