Closed camerow closed 1 year ago
I've tried a quick configuration change to see if I could get this to work, however it doesn't seem to find project level diagnostic information, though it does seem to find the correct file:
-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")
require("tsc").setup({
flags = {
build = true,
project = function()
local tsconfig = vim.fn.findfile("tsconfig.json", ".;")
local nxTsBaseConfig = vim.fn.findfile("tsconfig.base.json", ".;")
print("tsconfig", tsconfig)
print("nxTsBaseConfig", nxTsBaseConfig)
if nxTsBaseConfig ~= "" then
return nxTsBaseConfig
end
if tsconfig ~= "" then
return tsconfig
end
return nil
end,
},
}
As you can see, I'm using lazy.nvim
- perhaps there is a conflict there somewhere?
I'll take a look at this in the morning - any chance you could throw together a small nx repo that I can for sure reproduce this with?
I have one suspicion that the problem may be that I'm using vim.tbl_extend
instead of vim.tbl_deep_extend
here: https://github.com/dmmulroy/tsc.nvim/blob/main/lua/tsc/init.lua#L165
I'll also test that out in the morning and let you know what I come up with.
Sorry you're running into issues, but I appreciate the issue report ๐
On a personal note, I'm new to Neovim as of this week and really enjoying myself. If I can fix this issue I can make it my go to editor professionally at work!!!
Well then we'll definitely get it working for you ๐
Well I tried the tbl_deep_extend
option and didn't see much of a change - I cut a new release with the change anyways that you can try by upgrading (change here: https://github.com/dmmulroy/tsc.nvim/releases/tag/v1.8.0)
If you run tsc
manually from the root of your repo does it typecheck correctly?
I probably will need more info on your tsconfig and repo setup.
@camerow could you also try this configuration:
require("tsc").setup({
flags = {
noEmit = false,
build = true,
project = false,
},
})
Hey @dmmulroy, thank you so much for looking into this so quickly. I'm learning that the neovim community is rad!
I've tried both of those configurations however no luck with either. I'll take some time to setup a small repo that reproduces the issue, though it may take me a bit. My personal machine died recently and I don't want to push personal stuff from my work machine.
Once I get a new laptop I'll create a small repro.
If you get a wild hair and want to try it on your end before I get that computer you could basically do this, and create some kind of bad import/export and it does successfully repro the issue. Eg in apps/nx-nvim
create a BadExport.tsx
and import that into App.tsx
- something like that.
npx create-nx-workspace@latest
Need to install the following packages:
create-nx-workspace@latest
Ok to proceed? (y)
> NX Let's create a new workspace [https://nx.dev/getting-started/intro]
โ Where would you like to create your workspace? ยท nx-nvim
โ Which stack do you want to use? ยท react
โ What framework would you like to use? ยท expo
โ Application name ยท nx-nvim
โ Enable distributed caching to make your CI faster ยท Yes
> NX Creating your v16.8.1 workspace.
To make sure the command works reliably in all environments, and that the preset is applied correctly,
Nx will run "npm install" several times. Please wait.
โ Installing dependencies with npm
โ Successfully created the workspace: nx-nvim.
โ NxCloud has been set up successfully
That will run nx
locally and create a small repo that uses their default configs.
If you're seeing what I'm seeing running :TSC
won't return any errors, but if you open a buffer
Going to look into this after work today
@camerow I was able to reproduce your issue with the instructions you provided.
I was also able to get the plugin working - here is the configuration I used:
require("tsc").setup({
flags = {
project = "tsconfig.base.json",
jsx = "react",
},
})
๐พ That does seem to get project level errors working! Something else is wrong - likely a very specific thing in my work environment - which gives me tens of thousands of unresolved errors. Looks like package resolution or something, though I don't think it's something wrong on this plugin's end.
Thank you so much for your help and responses man! Truly appreciated ๐
Hopefully this little convo comes in handy for some other folks as well!
Awesome - lmk if you have any more issues, happy to help!
At work we used
nx
to generate our monorepo structure. We've got atsconfig.base.json
in the root of our project. The search function intsc.nvim
only looks fortsconfig.json
as far as I can tell.Could you give me some guidance with how to configure the options in
require('tsc").setup(...)
to find the correct root file?I've confirmed that I get project level diagnostics if I rename the file
tsconfig.base.json
->tsconfig.json
, however I know the team wouldn't appreciate me renaming this simply so that I can use Neovim.Thanks in advanced, and thanks for such a great tool!
On a personal note, I'm new to Neovim as of this week and really enjoying myself. If I can fix this issue I can make it my go to editor professionally at work!!!