Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extensions to be able to make requests to the typescript extension's tsserver via commands #138279

Merged
merged 3 commits into from
Dec 7, 2021

Conversation

orta
Copy link
Contributor

@orta orta commented Dec 1, 2021

This PR relates to microsoft/TypeScript-Website#2156 and #138211

This allows other extensions to make calls to the TypeScript Language Server, saving the need to create a second set of parallel tsservice-like infra in extensions like the typescript playground.


Tested by an extensions which calls:

console.log("Sending")
vscode.commands.executeCommand('typescript.tsserverRequest', 'emit-output', { file: "/Users/ortatherox/dev/js/berry/packages/plugin-git/sources/GitResolver.ts" } ).then(r => {
	console.log("Sent")
	console.log(r)
})

Which correctly returns the response to the request on the other side:

Screen Shot 2021-12-01 at 4 37 37 PM

@orta
Copy link
Contributor Author

orta commented Dec 1, 2021

( CI fails look unrelated )

Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good. I'm a little concerned about exposing this though since it gives extensions low level control and could make it difficult to understand why the server is in an odd state

What specific commands do you need to run for the playground?

@orta
Copy link
Contributor Author

orta commented Dec 7, 2021

Updated based on a chat we had yesterday.

I've removed my custom try catch error handling, at this point all the commands are reads and I don't think it should be possible to knock over the tsserver with them.

I don't know all of the commands the playground needs, but realistically it's probably a subset of the amount I've added here. It's enough to provide pretty solid introspection tooling.

@mjbvz mjbvz added this to the December 2021 milestone Dec 7, 2021
@mjbvz mjbvz merged commit fc4f41d into main Dec 7, 2021
@mjbvz mjbvz deleted the ts_server_req branch December 7, 2021 22:42
@mjbvz
Copy link
Collaborator

mjbvz commented Dec 7, 2021

Thanks! LGTM

@github-actions github-actions bot locked and limited conversation to collaborators Jan 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants