:TSC Command Doesn't Detect Errors with Split tsconfig
Current Behavior
In a project that uses a split tsconfig setup (e.g., tsconfig.app.json), running the :TSC command outputs "No errors found", even when there are errors.
However, if all configurations from tsconfig.app.json are merged into tsconfig.json, the command works as expected and detects errors immediately.
Expected Behavior
The :TSC command should detect and report all TypeScript errors across the entire project, even when using a split tsconfig setup.
Steps to Reproduce
- Create a new React + Vite project with TypeScript:
yarn create vite my-app --template react-ts cd my-app yarn - Open any file and introduce a syntax error.
- Run
:TSCin Neovim. - Observe that no errors are reported, even though they exist.
What I've Tried
1. Manually Setting the Project Path
Configured tsc.nvim to explicitly use tsconfig.app.json:
{
"dmmulroy/tsc.nvim",
config = function()
require("tsc").setup({
flags = {
watch = true,
project = "tsconfig.app.json"
},
})
end,
}
➡️ Result: Still doesn't detect errors.
2. Using a Dynamic Configuration (Based on #39)
local M = {}
local find_closest_file = require("plugins.utils.find-file").find_closest_file
local tsconfig_path = find_closest_file({ "tsconfig.app.json", "tsconfig.json" })
if tsconfig_path then
print(tsconfig_path)
M.plugin = {
"dmmulroy/tsc.nvim",
config = function()
require("tsc").setup({
flags = {
watch = true,
project = tsconfig_path
},
})
end,
}
else
M.plugin = {}
end
return M
➡️ Result: Correctly detects tsconfig.app.json or tsconfig.json dynamically, but :TSC still doesn't work.
Additional Notes
- The issue seems related to how
tsc.nvimresolves the project configuration. - Running
npx tsc --project tsconfig.app.jsonin the terminal correctly reports errors. - It’s unclear if
tsc.nvimis properly handling non-defaulttsconfigpaths.
Any insights or fixes would be appreciated! 🚀
I believe the issue is in this line: https://github.com/dmmulroy/tsc.nvim/blob/d38264b5712ce9dc2f39dff43121bbd164814528/lua/tsc/init.lua#L299
The project flag provided in the options is overriden by any tsconfig.json found by auto-detection logic.
@m4a1j9 As a workaround, it seems like passing flags as a string skips this logic and allows you to pass the project you need.
{
"dmmulroy/tsc.nvim",
config = function()
require("tsc").setup({
flags = "--watch --project=tsconfig.app.json",
})
end,
}
I think a solution to this is a) specifying your flags as a string, and b) including --build in your flags.
Example:
flags = "--build --noEmit"
The reason you need to specify your flags as a string is that --build must be the first argument to the TypeScript compiler, and tsc.nvim does not necessarily keep it in that position if you specify your flags as a table.
Passing --build makes the TypeScript compiler run for all references in your tsconfig.json, which might look like this in a vite project:
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
#71 should have hopefully resolved this 🤞