tsc.nvim
tsc.nvim copied to clipboard
Monorepo TSConfig Discovery
Hello, here's the text from the chat:
i have a monorepo with a tsconfig in /api/tsconfig.json and then one in /app/website/tsconfig.json
-- I see the build = true flag is supposed to hopefully seek these out,
but in the setup object, if i set flags.build = true, and open a ts file, it errors out that "project" is unset..
in the docs project is defined by
project = function()
return utils.find_nearest_tsconfig()
end, func
but i need to return two config files...
And here is a link to the monorepo:
https://github.com/jcmccormick/wc
@jcmccormick I am so sorry that I missed this issue - I'm going to spend some time next week (or the following) working on tsc.nvim
. Thank you for linking to that repo, I'll keep you posted on an update.
Not a problem!
I took some time to understand how tsc.nvim
works and made a small version of it I could play with for this issue.
https://gist.github.com/jcmccormick/691cd788793c8f225531c6a9b4429314#file-local-share-nvim-site-plugin-nvim_tsc-lua-nvim_tsc-init-lua
What ultimately fixed the problem IIRC is having a top level tsconfig file which referenced the other projects in the repo.
https://github.com/jcmccormick/wc/commit/0a6c86e62f9168a5b05d4962af1fb01f9f27eb30
Currently though I've since removed any of these configs from my repo. I think the reasoning was things were too slow (tsc in general) but I can't exactly remember. I'm more than happy to test anything you come up with though. I appreciate getting to learn what I did by going over tsc.nvim
!
Hi @dmmulroy. Just checking in on this issue to see if you looked into it. I ran into a similar issue as the OP, though with a turborepo based monorepo. I have a setup like: /.tsconfig /packages/database/.tsconfig (Prisma DB config, shared with all apps) /apps/dashboard/.tsconfig (Next app) /apps/bot1/.tsconfig (Bun based Discord bot) /apps/bot2/.tsconfig (Bun based Discord bot)
:TSC
while running nvim from the root of the project instantly returns a no problems found. I would have a file open with a TS error when doing this. :TSC
inside any of the apps or the database packages works fine within the scope of that project. I tried what the OP linked to but that doesn't seem to have any effect.
Unlike the OP, I do not get a error that project is unset.
I have not - I'll try to get around to looking into this tonight or tomorrow morning if I have time.
This PR might fix these issues: #46 It will allow watching of multiple typescript projects in a single instance of nvim