Skip to content

Silent fallback to unrelated global TypeScript when workspace uses TypeScript 7 (no tsserver.js) #1110

Closed

Description

@paul-vd

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

  1. A project whose node_modules/typescript is 7.0.1-rc (native typescript-go). Its lib/ contains only tsc.js, typescript.js, getExePath.js — no tsserver.js.
  2. A classic [email protected] happens to be installed globally next to typescript-language-server (e.g. npm/bun i -g typescript-language-server typescript).
  3. Start typescript-language-server --stdio with rootUri set to the project and send initialize.

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() builds path.join(libFolder, 'tsserver.js') and returns null because the TS7 install has no valid tsserver.js.
  • Resolution then falls to bundledVersion(), which does require.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions