neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.06k stars 68 forks source link

tsserver showing errors in React even after fixing them, corrects only after manual reload #401

Closed Yachint closed 2 years ago

Yachint commented 2 years ago

I keep having this issue that whenever I am writing writing jsx code, 5/10 times the errors are not getting refreshed even after saving. The errors were valid before but after I have fixed them it should not keep showing it, some errors are also shown without line indicators, like in the case below (showing 4 errors, but only 2 line indicators):

Screenshot 2022-09-10 at 9 15 45 PM

Also, in this case, I never had this error but still the server showing me this:

Screenshot 2022-09-10 at 9 47 44 PM

All gets fixed after I manually reload in nvim using ':e' command. I am not sure if this issue is coming from vim or tsserver but it seems like the server is not re-analyzing the file once it is written using ':w' or when we come to normal mode from insert. This does not happen all the time but as I said, 5/10 times it happens and I have to manually reload to fix it.

chemzqm commented 2 years ago

Check your coc.nvim version by :CocInfo, old version have bug with diagnostic refresh.

Yachint commented 2 years ago

Output of my ':CocInfo':

versions

vim version: NVIM v0.7.2 node version: v16.17.0 coc.nvim version: 0.0.82-347e33d7 2022-09-09 18:16:50 +0800 coc.nvim directory: /Users/yachintmacbook/.local/share/nvim/plugged/coc.nvim term: iTerm.app platform: darwin

I have updated Coc, nvim and also Tsserver to latest version. I have tested also on a Linux machine with similar results, will test a bit more scenarios to confirm. In the event that I still find the issue persisting, just wanted to confirm that nothing is wrong from tsserver end so that I can possibly raise an issue in Coc repo regarding diagnostic refresh.

Thanks

Yachint commented 2 years ago

Also, I have found a way to replicate it on both Linux and Mac systems, the version details for the Linux one are:

versions

vim version: NVIM v0.7.2 node version: v18.9.0 coc.nvim version: 0.0.82-b797c032 2022-09-04 21:59:01 +0800 coc.nvim directory: /home/yachint/.local/share/nvim/plugged/coc.nvim term: alacritty platform: linux

The replication steps are explained in the video link below: https://youtu.be/BtzG3WRyy_A (NOTE: Also tried the same with the .jsx extension and still same results)

Step details:

  1. Create a new file
  2. Add React import
  3. Create a dummy component
  4. Save and reload (':w' and ':e')
  5. Remove the React import
  6. Save and reload (':w' and ':e')
  7. Then attempt to add the import back

After 7th step, no matter how many times we save the file, the incorrect error is still shown. Only when we reload again, the error disappears.

I would be grateful if you could look into this and let me know if this issue is related to tsserver or Coc in general since it is only happening in React based files in my experience.

chemzqm commented 2 years ago

Confirmed bug of coc.nvim

Yachint commented 2 years ago

Thanks for the acknowledgment, let me know if I should open an issue in Coc.nvim regarding the same.

chemzqm commented 2 years ago

Fixed on latest release branch of coc.nvim.

Yachint commented 2 years ago

Thanks for the quick resolution, can confirm it has been fixed!