tsserver should implement the Language Server Protocol
Search Terms
language server protocol
Suggestion
As the language server protocol ( https://github.com/Microsoft/language-server-protocol ) is getting more and more popularity and clients ( https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations ), it would be very useful to have the tsserver implement this protocol.
This is a duplicate of issue #11274, which the OP closed because at that time, there existed two reasonable-looking LSP implementations for TypeScript.
But the times have changed. The Theia IDE now uses a VS Code extension for its TypeScript needs, and in the last eighteen months, Sourcegraph's server has received exactly one update by a sentient person.
There continue to be requests for LSP support within #11724 despite its Closed status. The OP has expressed no interest in revisiting the issue.
Use Cases
It would be useful to programmers who use TypeScript but don't use VS Code.
Checklist
My suggestion meets these guidelines:
- [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x] This wouldn't change the runtime behavior of existing JavaScript code
- [x] This could be implemented without emitting different JS based on the types of the expressions
- [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- [x] This feature would agree with the rest of TypeScript's Design Goals.
Is there any traction on this? I feel like this should be somewhat high priority, but only because my favorite IDE's all blame TypeScript's non-conformance to the Language Server Protocol as the reason TypeScript support is buggy.
How bad is this issue, and how difficult would it be to remedy? Thanks. I'd also be interested in links to reading material that might enlighten me on the subject.
We're working on this, albeit slowly. tsserver's implementation predates LSP so it's nontrivial work to move forward in a way that doesn't adversely affect old clients or result in code duplication.
Your favorite IDE should misplace their blame somewhere else 🙃
@RyanCavanaugh If you are looking for a testing environment may I suggest vim with vim-lsp.
@RyanCavanaugh is there a branch to track? Or what is the best way to track the work on that?
@RyanCavanaugh In line with last comment: any list of issues/tasks that someone could tackle on free time to help with this?
From Eclipse Wild Web Developer perspective, we'd also gladly participate in some testing of this feature when it's available for experiments. We're not looking for a 100% LSP conformance from day 1, we're just looking for a sustainable and more standard alternative to the https://github.com/theia-ide/typescript-language-server and we'd gladly migrate to standard tsserver LSP support even if we lose a few features by the way. We'll more easily be able to contribute to tsserver after we can have a minimum viable experimental LSP support.
I don't have any major updates; as Ryan mentioned, the work is happening bit by bit, but we are working on it so I've at least labeled the issue as such. One thing that @minestarks mentioned to me is that it would be good to have a channel with implementers who plan to use an LSP server so that we can potentially coordinate and hear more about use-cases. If you're an LSP client implementer, I'd encourage you to just drop a reply here.
I'm not directly an LSP client implementer, but I'm hoping to use tsserver as a language server in https://github.com/apexskier/nova-typescript as a language server for Nova instead of typescript-language-server.
And I am willing to help with any tasks that might help @apexskier achieve that goal because I much prefer Nova and I work all day on build tools for large TypeScript monorepos.
@DanielRosenwasser
more about use-cases.
I guess we all(lsp client maintainers) have one use-case - we want to access the tsserver functionality via LSP protocol to avoid the need to support multiple protocols.
If you're an LSP client implementer, I'd encourage you to just drop a reply here.
@leungbk and I are maintainers of Emacs LSP client - https://emacs-lsp.github.io
@DanielRosenwasser I'd be interested in being included - I'm the maintainer of typescript-language-server, which uses tsserver internally :)
@joaotavora, the author of eglot, another LSP client for Emacs, may also be interested.
cc @prabirshrestha @hrsh7th
I was asked to comment on this, as ALE implements the tsserver protocol quite thoroughly. I think supporting Language Server Protocol would be good. I would like to make two recommendations.
- Whenever you
npm install typescript, make sure that also installs a language server you can execute from the CLI. - Update Language Server Protocol to support explicit diagnostic requests: https://github.com/microsoft/language-server-protocol/issues/737
Because you always get tsserver in node_modules whenever you install typescript, ALE is able to run the language server automatically and report problems for any project that uses TypeScript. You might have to go out of your way for it not to work automatically.
One thing tsserver does better than LSP servers is that you can control when diagnostics will be sent to the client. I explained more in the issue I linked above. I would miss that feature if tsserver was ever replaced with an LSP server. A common complaint I see from ALE users is that they see errors in their editor when they are just using autocompletion, and that's because LSP servers just send diagnostics whenever they want, often in response to documents changing.
Thanks to all who have commented so far, it's helpful to get context on the various use cases for this, and to learn from the experience of those who have already built LSP adapters. We'll be reviewing how to proceed (admittedly, slowly) while maintaining both compatibility and flexibility... and hopefully have updates to share before long!
@DanielRosenwasser @minestarks feel free to reach out to me in regards to Deno. We have been re-implenenting a lot of the Language Server in TypeScript to provide a Deno Language server and doing similar transforms that VSCode does in Rust. Be more than glad to chat about it. No real challenges, but in some cases there is actually quite a lot of logic (like CodeActions).
is it possible to make a bridge from tsserver to lsp?
is it possible to make a bridge from tsserver to lsp?
That's the purpose of https://github.com/theia-ide/typescript-language-server ; but maintenance, usage and evolution would be much simpler if LSP support is built-in directly in tsserver. Additionally, having tsserver able to talk LSP natively, additionally or alternatively to its own protocol, seems very consistent with the goals of tsserver itself.
@DanielRosenwasser I'd be interested in testing this in gnome-builder (I started looking into a typescript plugin a while back but that hit a dead end when I found out tsserver doesn't support LSP, so I'd love to have another look).
I'm a Vetur maintainer. Vetur is a Vue language support extension in vscode. https://github.com/vuejs/vetur The vls is a Vue language server in Vetur. We provide JavaScript/TypeScript features with TypeScript language service.
If typescript can support LSP and enough flexible options, Vetur can use it and reduce many maintenance costs. In the past, we need to align LSP with TypeScript language service and VSCode.
Hi. Any progress or more concrete plans towards that ?
If typescript can support LSP and enough flexible options, Vetur can use it and reduce many maintenance costs.
Does Vetur actually gain any benefit from an LSP client? When I last contributed to it, Vetur just directly spun up its own TypeScript service instance (as opposed to a server) because it needed to create virtual files for the service.
Hi TypeScript team, any update on this? I'm personally much (!) more helped with a LSP server than any language feature.
Additionally, looking at effort put in other places (language features / vscode itself), I'm a bit worried for an "embrace, extend, and extinguish"? Hopefully utterly unfounded, if so forgive me, an IE5+ survivor speaking here.
Thanks for the work on TS!
If there are concrete plans, we'd love to contribute and push this forward... since otherwise we'll need to do work around this limitation!
Hi. I do not know the architectures discussed in this post, I only understand that I'm stuck to using old versions of Eclipse because tsserver does not use LSP protocol. In the main page of Typescript project I read:
"TypeScript is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the playground, and stay up to date via our blog and Twitter account."
Can anyone point me out a Javascript IDE using Typescript, that allows "application-scale" developers to surf and jump happily around their application ? I'm ready to dump Eclipse for that.... Well not entirly to be honest, I'm still developing in java.
@MonNomIzNoGoud based on what you said, VSCode would be the best choice. If you really want to have a single IDE for both Java and Javascript, IMO Intellij is the best way to go - it has amazing Java support, and you can install Javascript plugins onto non-community versions of it.
If typescript can support LSP and enough flexible options, Vetur can use it and reduce many maintenance costs.
Does Vetur actually gain any benefit from an LSP client? When I last contributed to it, Vetur just directly spun up its own TypeScript service instance (as opposed to a server) because it needed to create virtual files for the service.
You're right. But the LSP client will also be based on typescript service. If he is designed to be replaceable, I think Vetur could also benefit from it. Step back, Aligning TypeScript service and LSP will also be easy in vetur.
I've been watching this issue for a while, and the discussion is getting a bit weird. As far as I can see, work is in progress for this, and when it's all ready the rest will follow easily.
It's what I most long for in my email box now. Random comments from this issue 😂
On Fri, Jun 4, 2021, 16:04 w0rp @.***> wrote:
I've been watching this issue for a while, and the discussion is getting a bit weird. As far as I can see, work is in progress for this, and when it's all ready the rest will follow easily.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/TypeScript/issues/39459#issuecomment-854798242, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7WGR4WKS4MVO375IXZKDTTRDTQXANCNFSM4OSKRTMQ .
@VVKot I've stumbled into VSCode some long time ago. It didn't seem close to Eclipse's level but I'll give it another go...
For instance in the following code
(function () { var global = this || window; var _Ctrls = null; _Ctrls = global.Ctrls = { test: function() { ////// }, test2: function() { _Ctrl.test(); } }; })
Asking to Go To Definition when you're on the _Ctrl.test() would only work in JSDT, a dead (?) project.
Also when you just type this in a js file in Eclipse:
$.jqplot.RadarXAxisRenderer.prototype.init = function(options) {}
You automatically have a little green arrow on the left that allows you to go to the method you just overrid in the jqplot project.
VSCode couldn't do this...
@dagadbm So you're the one sabotaging this issue's happy ending, you just want random comments to laugh about. How about doing some actual work, eih ?