Skip to content

fix(language-server): accept a typescript.tsdk package folder, warn when the folder has no TypeScript (#1013) - #1015

Merged
leonidaz merged 7 commits into
mainfrom
fix/language-server-tsdk-warning-1013
Oct 3, 2026
Merged

leonidaz merged 7 commits into
mainfrom
fix/language-server-tsdk-warning-1013

Conversation

@leonidaz

@leonidaz leonidaz commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1013.

What changes

Project on TypeScript 5.9.3, TypeScript 6.0.2 installed in /ts6:

typescript.tsdk Before Now
/ts6/node_modules/typescript/lib runs 6.0.2 runs 6.0.2
/ts6/node_modules/typescript (the package folder) runs 5.9.3, no message runs 6.0.2
/ts6/typo/lib (does not contain TypeScript) runs 5.9.3, no message runs 5.9.3 and shows a warning

The package folder works. When the folder is the typescript package itself, the server uses its lib folder. Picking the package folder instead of lib is the easy mistake from the issue, and the server can fix it without asking the user.

A folder that does not contain TypeScript gets a warning. For /ts6/typo/lib:

The TSRX language server does not use the typescript.tsdk startup option.
The folder in this option does not contain TypeScript: /ts6/typo/lib.
The server uses TypeScript 5.9.3 from the project instead: /project/node_modules/typescript.
Set this option to the lib folder of a TypeScript installation, for example /path/to/node_modules/typescript/lib.

(One line in the editor; split here to read more easily.)

  • When the TypeScript comes from the server's own folder, the third sentence says "from the server installation".
  • When the server does not find a TypeScript it can run (none, or TypeScript 7), the third sentence is left out. The "no TypeScript" or "TypeScript 7" warning then follows as a second message.

Plainer warnings. All three warnings now follow the ASD-STE100-style rules: short, active sentences; first the cause, then its effect, then one action per sentence; one name for each thing. For example, the TypeScript 7 warning:

The TSRX language server found TypeScript 7.1.0-dev.20261002.1 in /project/node_modules/typescript.
The server cannot run TypeScript 7 or newer.
The TSRX language server will not be able to provide type checking, hover or completions in .tsrx files.
These features still work: TSRX compile errors, CSS in <style>, the outline, formatting and closing tags.
To use TypeScript 7, run the TypeScript 7 language server (tsc --lsp) with @tsrx/content-mapper.
To use a different TypeScript, set the typescript.tsdk startup option to the lib folder of that TypeScript.
For more information, see https://github.com/tsrx-org/tsrx/tree/main/packages/language-server#which-typescript-it-uses

Before: "The TSRX language server found typescript 7.1.0-dev.20261002.1 at /project/node_modules/typescript. It cannot run TypeScript 7 or newer, so type checking, hover and completions in .tsrx files are off. …"

This only applies on the classic backend, when the editor passes typescript.tsdk: Zed, Neovim and Sublime Text through initializationOptions, and the JetBrains plugin through Settings → Languages & Frameworks → TSRX → TypeScript lib folder (#1012). VS Code uses the plugin backend and passes no tsdk, so nothing changes there.

How

  • find-typescript.js:
    • find_typescript tries the option's folder as the lib folder first, then as the package folder.
    • New tsdk_notice(tsdk, found) writes the warning.
    • typescript_notice (no TypeScript, TypeScript 7) is reworded; the facts and actions stay the same.
  • server.js: when typescript.tsdk is set and the TypeScript found did not come from it, the server adds the tsdk warning. The warnings are now a list, and each one is sent as its own window/showMessage notification after initialized.
  • backend.js: the comment on resolve_typescript_tsdk said the server falls back to the typescript next to itself. Since fix(language-server): find the project's typescript, and start without one (#1008) #1011 it searches the project first.
  • nvim-plugin and zed-plugin editor tests: the warning patterns match the new texts. The 4 Neovim scenarios pass locally (headless Neovim); the Zed scenarios were not run.
  • README: "Which TypeScript it uses" now says the package folder works too, and what happens when the folder does not contain TypeScript.

Tests

  • findTypeScript.test.js:

    • find_typescript accepts the lib folder and the package folder, and skips folders that do not contain TypeScript.
    • The full text of all three warnings, including the tsdk warning when the fallback TypeScript is the project's, the server's, or none.
  • typescriptDiscoveryLsp.test.js runs the built server over stdio, the way other editors start it:

    • tsdk is the package folder and the project has TypeScript 7: TypeScript features are on, with no warning.
    • tsdk is a missing folder and the project has TypeScript 5.9: TypeScript features are on, with one warning (exact text).
    • tsdk is a missing folder and the project has TypeScript 7: the tsdk warning comes first, then the TypeScript 7 warning.

    All three fail on main and pass here. Both warnings arrive right after initialized, so the session helper now starts waiting for the first and the second warning before initialize.

Local runs: pnpm vitest run --project language-server (158 passed), tsc -p packages/language-server/tsconfig.typecheck.json, prettier --check, pnpm changeset:check.

Repro script
S=$(mktemp -d)
mkdir -p "$S/project/node_modules/typescript/lib" "$S/ts6/node_modules/typescript/lib"
echo '{"name":"typescript","version":"5.9.3"}' > "$S/project/node_modules/typescript/package.json"
echo '{"name":"typescript","version":"6.0.2"}' > "$S/ts6/node_modules/typescript/package.json"
node --input-type=module -e "
import { find_typescript, tsdk_notice } from './packages/language-server/src/find-typescript.js';
const S = '$S';
for (const tsdk of [S + '/ts6/node_modules/typescript/lib', S + '/ts6/node_modules/typescript', S + '/ts6/typo/lib']) {
	const found = find_typescript({ tsdk, workspace_dirs: [S + '/project'], server_dir: S + '/project' });
	console.log(tsdk.replace(S, '<tmp>'), '->', found.version, found.source);
	if (found.source !== 'tsdk') console.log('  warning:', tsdk_notice(tsdk, found).replaceAll(S, '<tmp>'));
}
"

🤖 Generated with Claude Code


Note

Low Risk
Changes are limited to TypeScript discovery and user-facing warnings on the classic backend; VS Code’s plugin backend is unaffected.

Overview
Fixes typescript.tsdk handling on the classic backend so editors can pass either the TypeScript lib directory or the typescript package folder (e.g. node_modules/typescript). Invalid or empty paths are no longer ignored silently: the server emits a new tsdk_notice warning naming the bad folder, which TypeScript it uses instead (when applicable), and how to set the option, then continues workspace/server discovery.

No-TypeScript and TypeScript 7 user messages are reworded into shorter, clearer sentences (impact → cause → action). Warnings are collected in a list and each is sent as its own window/showMessage after init, so a bad tsdk can appear before the TS7/missing-package warning. README and changeset document the behavior; unit, LSP integration, and Neovim/Zed editor tests assert the new resolution and copy.

Reviewed by Cursor Bugbot for commit 37d0903. Bugbot is set up for automated code reviews on this repo. Configure here.

leonidaz and others added 2 commits October 2, 2026 20:12
…ib folder (#1013)

The typescript.tsdk startup option must name the lib folder of a
TypeScript install. When it named another folder, such as the typescript
package folder or a wrong path, the classic backend skipped it, used the
project's typescript, and told the user nothing.

The server now sends a window/showMessage warning that names the folder,
gives the lib folder to use when the folder is the typescript package,
and names the TypeScript it runs instead. When it then finds no
TypeScript it can run, the existing warning follows as a second message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ipt.tsdk

When typescript.tsdk names the typescript package folder instead of its
lib folder, use its lib folder rather than warn. The warning is now only
for a folder with no TypeScript, and reads in order: what is wrong,
which TypeScript the server uses instead (the project's, or the one next
to the server), and how to set the option.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@leonidaz leonidaz changed the title fix(language-server): warn when typescript.tsdk is not a TypeScript lib folder (#1013) fix(language-server): accept a typescript.tsdk package folder, warn when the folder has no TypeScript (#1013) Oct 3, 2026
leonidaz and others added 5 commits October 2, 2026 23:11
Rewrite the typescript.tsdk, no-TypeScript and TypeScript 7 warnings in
short, active sentences: first the effect, then the cause, then one
action per sentence. One name for each thing: "TypeScript", "the
typescript.tsdk startup option", "the server installation". Update the
Neovim and Zed editor-test patterns to match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rnings

Put the negation on the verb: "does not contain TypeScript", "did not
find TypeScript", "does not give type checking". Same in the README,
the changeset, and the comments and test names of this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first sentence of the no-TypeScript and TypeScript 7 warnings said
"The TSRX language server does not provide type checking, …", which
reads like a fact about the product when nothing comes before it. Open
with what the server found, then "Because of this, the server does not
provide …".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… warnings

Replace "Because of this, the server does not provide …" with "The TSRX
language server will not be able to provide …" after the cause sentence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@leonidaz
leonidaz merged commit 495323e into main Oct 3, 2026
8 checks passed
@leonidaz
leonidaz deleted the fix/language-server-tsdk-warning-1013 branch October 3, 2026 03:29
@github-actions github-actions Bot mentioned this pull request Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: language-server: a typescript.tsdk folder with no TypeScript in it is skipped without a warning

1 participant