#6895

typescript-lsp: hovers right after a file opens show no types (syntax server)

Openmhrstmnnopened 4d ago

typescript-language-server starts a syntax-only tsserver next to the full one by default (tsserver.useSyntaxServer: "auto"), and the syntax server answers requests while the project is still loading. It knows no types, so the first hover after Claude opens a file comes back without them:

import clsx

instead of

(alias) function clsx(...inputs: ClassValue[]): string
import clsx

A person in an editor hovers again a moment later. Claude takes the first answer, and may conclude the types don't resolve.

Steps: in any project with typescript-lsp installed, ask Claude to use the LSP tool to hover over an imported name in a .ts file as its first LSP call. Asked again a few seconds later, the same hover shows the type.

Fix: turn the syntax server off in the plugin's server entry, so every request goes to the full server and waits until the project has loaded:

"initializationOptions": { "tsserver": { "useSyntaxServer": "never" } }

That also saves one tsserver process per project. In my tests the first hover then included the type, and diagnostics were unchanged.

Activity

0

No activity yet.