Repository navigation
feat(intellij-plugin): choose the TypeScript the language server runs (#1009) - #1012
Merged
Merged
Conversation
…#1009) Add a per-project "TypeScript lib folder" setting under Settings → Languages & Frameworks → TSRX. When it is set, the plugin starts @tsrx/language-server with { "typescript": { "tsdk": "<path>" } } as initialization options; a relative path is resolved against the project folder first. Applying a change restarts the TSRX server. The service and settings page are registered in tsrx-lsp.xml, so syntax-only IDEs do not load them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The setting is saved trimmed. Reset the page after Apply so the field shows the saved value and the page is no longer marked as modified. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1009
What you see
JetBrains IDEs with the LSP module (WebStorm, IntelliJ IDEA Ultimate, …) get a new settings page:
Settings → Languages & Frameworks → TSRX
What the plugin sends to
@tsrx/language-serverininitialize:initializationOptionstypescriptitself/Users/me/ts6/node_modules/typescript/lib{ "typescript": { "tsdk": "/Users/me/ts6/node_modules/typescript/lib" } }node_modules/typescript/lib(project at/work/app){ "typescript": { "tsdk": "/work/app/node_modules/typescript/lib" } }../ts6/lib(project at/work/app){ "typescript": { "tsdk": "/work/ts6/lib" } }When you press Apply or OK and the value changed, the TSRX server for that project restarts, so the new TypeScript is used right away. Applying the same value again does not restart it.
Design
PersistentStateComponent(TsrxSettings, aSimplePersistentStateComponentwith aBaseState), saved in.idea/tsrx.xml. The value is trimmed; an empty value is stored as nothing. After Apply, the field shows the saved (trimmed) value.TsrxSettingsConfigurable, a Kotlin UI DSLBoundConfigurablewith a folder chooser (FileChooserDescriptorFactory.singleDir()), underparentId="language",nonDefaultProject="true".tsrx-lsp.xml(loaded only throughtsrx-ultimate.xmlwhen the IDE has the Ultimate and LSP modules), not inplugin.xml. Syntax-only IDEs load neither class and show no page that would do nothing.TsrxPluginPackagingTestnow checks this.tsdkwithpath.resolve(tsdk), that is against its own working directory. The plugin starts it inserverInfo.root, the nearest folder withpackage.json,pnpm-workspace.yamlor.gitabove the.tsrxfile that started it, which can be a sub-package in a monorepo. So the plugin resolves a relative setting againstproject.basePathfirst and always sends an absolute, normalized path. With no project folder, a relative setting is dropped (no options sent).TsrxSettingsConfigurable.apply()compares the value before and after and callsLspServerManager.stopAndRestartIfNeeded(TsrxLspServerSupportProvider::class.java). That call was already used after the managed server install; it is now one helper,restartTsrxLanguageServer, used in both places. The restart builds a newTsrxLspServerDescriptor, whosecreateInitializationOptions()reads the current setting.resolve_typescript_tsdkinbackend.jsreadsinitializationOptions.typescript.tsdk, which is exactly what is sent. The server's warning says to "set the typescript.tsdk startup option"; the README now says the IntelliJ setting passes the folder as that option.Docs and changeset
packages/intellij-plugin/README.md: the "Which TypeScript the language server uses" section now explains the setting (where it is, an example, relative paths, restart, where it is saved), in place of the "no setting yet" note..changeset/intellij-plugin-typescript-lib.md:patchfor@tsrx/intellij-plugin.Validation
Locally (macOS, Gradle 9.0.0 on Temurin 25):
packages/intellij-plugin/gradlew -p packages/intellij-plugin test verifyPluginProjectConfiguration buildPlugin verifyPluginStructure verifyPlugin: build successful, 65 tests, 0 failures. Plugin Verifier:Plugin tsrx.intellij-plugin:0.0.86 against WS-252.27397.92: Compatible, with no deprecated, experimental or internal API usages reported.TsrxInitializationOptionsTest: empty and blank setting → no options; absolute path; relative path → resolved against the project folder (including./…/and../…); relative path without a project folder → no options; whitespace trimmed.TsrxLspIntegrationTest: the descriptor sends options only when the project setting is set; the settings page restarts the server once per real change, not when nothing changed or only spaces were added, and shows the trimmed value after Apply.pnpm test --project intellij-plugin: 11 passed.pnpm changeset:checkandpnpm format: clean.Not done: a manual check in a running IDE (
runIde). The page, its folder chooser and the restart are covered only by the tests above.Related finding
If the setting names a folder with no TypeScript in it (for example the
typescriptpackage folder instead of itslibfolder), the server skips it and uses the project'stypescriptwithout a warning. That is server behavior, so it is filed separately as #1013 and not changed here.🤖 Generated with Claude Code
Note
Low Risk
IDE configuration and LSP startup options only; no changes to server auth, data handling, or core compile paths beyond which TypeScript SDK is selected.
Overview
Adds a project-level Settings → Languages & Frameworks → TSRX page with TypeScript lib folder, persisted in
.idea/tsrx.xml. When set, the plugin sends LSPinitializationOptionsas{ "typescript": { "tsdk": "<absolute lib path>" } }so@tsrx/language-servercan run a different TypeScript (e.g. TS 6 while the project uses TS 7). Empty value keeps the previous behavior (server discovers the project’stypescript).Relative paths are resolved against the project folder before startup (so monorepo package roots don’t mis-resolve
tsdk). Applying a changed setting—or finishing a managed server install—restarts the TSRX LSP via a sharedrestartTsrxLanguageServerhelper. Settings and the configurable register only intsrx-lsp.xml(LSP-capable IDEs). README and a patch changeset document the feature; unit/integration tests cover path resolution, init options, restart-on-apply, and packaging.Reviewed by Cursor Bugbot for commit c8f3a2a. Bugbot is set up for automated code reviews on this repo. Configure here.