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

coc-tsserver not recognizing @types/node #474

Open gatoasmatico opened 1 month ago

gatoasmatico commented 1 month ago

I'm on windows, using vim through MSYS2, and i'm trying to use coc-tsserver to work on a Nodejs project, but the extension isn't recognizing node built-in modules, not even the global variables like Buffer. Is this a problem from MSYS or the extension? image

I also noticed that :CocConfig is not auto-completing some tsserver configuration options like "tsserver.log" image

I also use this extension on my Android through termux and it works perfectly. Node and NPM have been installed from nodejs.org and can be accessed by MSYS via "MSYS2_PATH_TYPE=inherit" in msys2.ini. I've already run both npm install typescript @types/node and npm install --global typescript @types/node. I can provide tsserver.log, but I don't think I should just paste the text here because it has many lines, so if anyone wants me to send the tsserver.log, please tell me the best way.

fannheyward commented 1 month ago

Try import http from 'node:http', looks like something wrong in your tsconfig.json?

gatoasmatico commented 1 month ago

I replaced const http = require("node:http") with import http from 'node:http' and it still doesn't recognize it. I don't have a tsconfig.json file because I'm not using TypeScript, I'm using JavaScript.

fannheyward commented 1 month ago

Check the QA in README https://github.com/neoclide/coc-tsserver?tab=readme-ov-file#q--a

You need to setup jsconfig.json to make tsserver understand your code.

gatoasmatico commented 1 month ago

I created a jsconfig.json on my project root with { "include": ["./main.js"], "module": "ES6", "checkJs": true } , i added npm global path and the coc-status line, which only shows "Initializing tsserver" and "TSC 5.6.2". Nothing has changed, still not recognizing.

gatoasmatico commented 1 month ago

I ran npm --global install typescript@5.5 and configured tsserver.tsdk to use it and now it works! image

When I was trying to figure out why it was working in termux but not in MSYS, I noticed that the TSC version in my termux was 5.5.4.