Repository navigation
Description
Summary
When a workspace pins [email protected] (the native typescript-go build, which ships no lib/tsserver.js), the server's version resolver silently falls through to bundledVersion() and picks up an unrelated, incidentally-installed global [email protected], then reports success. The editor gets language features from a TypeScript version that has nothing to do with the project, with no warning that the project's actual TypeScript was skipped.
This is not a request to add TS7 language support — I understand the native Go server speaks LSP directly and the README already notes it "will hopefully supersede this project." The ask is narrower: fail loudly instead of silently substituting the wrong compiler.
Steps to reproduce
- A project whose
node_modules/typescriptis7.0.1-rc(nativetypescript-go). Itslib/contains onlytsc.js,typescript.js,getExePath.js— notsserver.js. - A classic
[email protected]happens to be installed globally next totypescript-language-server(e.g.npm/bun i -g typescript-language-server typescript). - Start
typescript-language-server --stdiowithrootUriset to the project and sendinitialize.
Actual behavior
The server logs:
Using Typescript version (bundled) 6.0.3 from path ".../node_modules/typescript/lib/tsserver.js"
and returns a normal initialize response advertising full capabilities. It silently ignored the project's pinned [email protected] and adopted an unrelated global TS 6.0.3. Real requests then reflect the wrong compiler (or, on a machine with no global classic TypeScript, the server instead throws Could not find a valid TypeScript installation... Exiting.).
Root cause (pointer)
src/tsServer/versionProvider.ts:
getWorkspaceVersion()buildspath.join(libFolder, 'tsserver.js')and returnsnullbecause the TS7 install has no validtsserver.js.- Resolution then falls to
bundledVersion(), which doesrequire.resolve('typescript')relative to the language server's own module location — resolving a sibling global[email protected]rather than the workspace's TypeScript.
There is no signal to the user that the workspace's own TypeScript was skipped.
Expected behavior
When getWorkspaceVersion() finds a workspace typescript package whose lib/ has no tsserver.js (a strong indicator of TypeScript 7 / typescript-go), the server should surface a clear window/showMessage warning — e.g. "Workspace uses TypeScript ≥7 (typescript-go), which has no tsserver.js; falling back to bundled TypeScript X.Y — language features will not reflect the project's compiler. Use the native LSP (tsc --lsp --stdio) instead." — rather than silently substituting an unrelated version. Ideally distinguish "no TypeScript at all" from "TypeScript present but has no tsserver.js (native build)".
Environment
- typescript-language-server 5.3.0
- workspace typescript: 7.0.1-rc (native typescript-go); global fallback: typescript 6.0.3
- node v24.18.0, macOS arm64
Activity