I want to use the syntastic plugin for vim to give me live error checking while I'm writing typescript files, using tsc. I already have tsc activated in vim. Any suggestions for how I could get tsc to use the closest parent's tsconfig.json file as configuration? I find that tsc doesn't do so by default, which makes syntastic configuration difficult. Thanks!
EDIT: The reason I think it's not using tsconfig.json is because options like the module resolution method doesn't seem to be working ("require" not defined), and it also isn't catching my definition files as defined in the files attribute in tsconfig.json.
My failed attempt to solve this:
let g:syntastic_typescript_checks=['tsc', 'tslint']
" typescript: find tsconfig.json
function! FindTypescriptRoot()
return fnamemodify(findfile('tsconfig.json', './;'), ':h')
endfunction
let g:syntastic_typescript_tsc_args=['-p', FindTypescriptRoot()]
This results in Syntastic spitting out to me this error:
app.ts|| TS5042: Option 'project' cannot be mixed with source files on a command line.
This is probably because it's running a command like tsc -p /path/to/project/ app.ts, which is an illegal use of that flag... But I don't understand why my settings in tsconfig.json are being ignored by syntastic :(
Add let g:syntastic_typescript_tsc_fname = '' to .vimrc.
As romainl mentioned in his answer, the "Using tsconfig.json" section of the Typescript wiki states:
By invoking tsc with no input files, in which case the compiler searches for the
tsconfig.jsonfile starting in the current directory and continuing up the parent directory chain.
You can do this in Vim using Syntastic by adding the following to your .vimrc, or .vimrc.after if you use Janus, as found in LCD 047's answer to your Syntastic issue #1628:
let g:syntastic_typescript_tsc_fname = ''
The wiki says:
Using tsconfig.json
By invoking
tscwith no input files, in which case the compiler searches for thetsconfig.jsonfile starting in the current directory and continuing up the parent directory chain.By invoking
tscwith no input files and a-project(or just-p) command line option that specifies the path of a directory containing atsconfig.jsonfile.When input files are specified on the command line,
tsconfig.jsonfiles are ignored.
So, basically, you need to find a way to tell Syntastic to not pass the filename to tsc.
I'd suggest using their issue tracker from now on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With