Ale: tsserver doesn't handle new files correctly some of the time

Created on 28 Nov 2017  路  10Comments  路  Source: dense-analysis/ale

I haven't been able to figure out exactly why this happens, but sometimes tsserver doesn't work properly with new files, and then after a while it does. Imports and such don't work, and then later they do.

bug

Most helpful comment

I think the problem lies in tsserver. It doesn't watch the filesystem for changes, so it doesn't know what to do with new files. I have added a command for stopping tsserver and all other lsp-like things to work around this now. See :help ALEStopAllLSPs.

All 10 comments

My hunch is that a didSave event needs to be sent when new files are created.

In my case - I can constantly reproduce this issue.

  1. start neovim
  2. open typescript file, so tsserver starts
  3. copy some correct file to another location using file manager
  4. open copy with neovim

ale highlights local imports.
also seems that tsserver don't use project tsconfig.json for new files.

I'm having the same issue when following the steps from @rapthead. Any imports that require baseUrl from tsconfig.json get highlighted as errors, while imports from node_modules seem to be fine.

I think the problem lies in tsserver. It doesn't watch the filesystem for changes, so it doesn't know what to do with new files. I have added a command for stopping tsserver and all other lsp-like things to work around this now. See :help ALEStopAllLSPs.

I verified that the same issue exists in vscode, so you're probably right that it might be a tsserver thing. I was hoping to find that it works in vscode so I could figure out the difference, but alas...

When I looked through the tsserver logs it looked like it was assuming my new file to be its own inferred project root, not sure what's up with that.

@w0rp tsserver has watch mode. Passing -w or (I believe) --watch would solve this problem.

I think that option exists for tsc, but not for tsserver.

Well, I have modified ale/ale_linters/typescript/tsserver.vim and added -w flag to command. That solved the problem for me of ale not working anymore on file rename.

Okay. I couldn't see it documented anywhere. I'll have to dig around to figure out what versions of tsserver support that.

Now I'm looking into ale code and what I have done and I think I did something stupid. As well I have looked into tsserver code and there shouldn't be -w option unless it is well hidden somehow. Still, while stupid that somehow solved my problem. One possibility is that it is somehow related to the fact that another plugin that starts tsserver is https://github.com/mhartington/nvim-typescript.

Could it be that my naive approach how to pass "-w" to tsserver in Ale broke tsserver for Ale and in result it somehow ended using tsserver instance that was run by nvim-typescript's? I see that nvim-typesript is issuing TSServer reload command before executing any other TSServer command. Maybe that would be the correct fix?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sublee picture sublee  路  3Comments

ianchanning picture ianchanning  路  3Comments

aressler38 picture aressler38  路  3Comments

catbaron0 picture catbaron0  路  3Comments

chauncey-garrett picture chauncey-garrett  路  3Comments