vtsls icon indicating copy to clipboard operation
vtsls copied to clipboard

ts definitions on javascript file not working

Open brunobmello25 opened this issue 1 year ago • 7 comments
trafficstars

This happens when working with some nodejs libraries in a js project. Steps to reproduce:

npm init -y
npm install @slack/bolt
touch main.js

now open main.js and import App from slack bolt

const { App } = require("@slack/bolt")

const app = new App({
  ... // try to get intellisense here
})

When using tsserver this gives us proper type definitions for all properties, but when using with vtsls we get nothing.

brunobmello25 avatar Jan 12 '24 18:01 brunobmello25

I don't have much experience with lsp's (never wrote anything related to it, just used them) but I'd be glad to try helping solving this . Let me know if you need anything

brunobmello25 avatar Jan 12 '24 18:01 brunobmello25

Could you check if other LSP features like hover doc work normally? Does the basic completion for keywords like import and const also not work? LSP log from the client could make it easier for troubleshooting.

yioneko avatar Jan 14 '24 02:01 yioneko

yep, basic keywords completion work normally: image

Hover docs also work, it's just type definitions that aren't working properly. image

My lsp logs don't seem to have any relevant information regarding vtsls:

[START][2024-01-14 23:28:38] LSP logging initiated
[WARN][2024-01-14 23:28:38] ...lsp/handlers.lua:134     "The language server copilot triggers a registerCapability handler for workspace/didChangeWorkspaceFolders despite dynamicRegistration set to false. Report upstream, this warning is harmless"

brunobmello25 avatar Jan 15 '24 02:01 brunobmello25

I might have failed to explain the problem more clearly: lsp features are working fine, but when using vtsls with javascript files specifically (not typescript files) there are no type definitions.

brunobmello25 avatar Jan 15 '24 02:01 brunobmello25

I think this is the same issue: https://github.com/microsoft/vscode/issues/196554, should be fixed in HEAD (not released yet).

You can set moduleResolution to Node in your tsconfig.json to temporarily solve this.

yioneko avatar Jan 15 '24 04:01 yioneko

I don't really have a tsconfig file since it's a js only project =/ But I'll see if I can figure something else out. Thanks!

One other thing: I tested opening up vscode on the same project here and in vscode the type definitions are loading file, at least in vscode 1.85.1 (commit 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2)

Maybe vtsls is using an older lsp version than what this vscode version uses?

brunobmello25 avatar Jan 15 '24 13:01 brunobmello25

Maybe vtsls is using an older lsp version than what this vscode version uses?

Yes, the last syncing to VSCode of the current latest release version of vtsls is at https://github.com/yioneko/vtsls/pull/108, which is before the fix landed on the upstream: https://github.com/microsoft/vscode/commit/60182c7e1a666961ded4d0319c154f52d85daf30. The next release should fix this.

yioneko avatar Jan 15 '24 13:01 yioneko