Skip to content

TypeScript 7 VS Code extension: let other extensions send requests to tsc --lsp, like typescript.tsserverRequest #64580

Description

@leonidaz

VS Code's built-in TypeScript extension lets other extensions send requests to its server with the typescript.tsserverRequest command: built-in requests from a short list, and any request whose name starts with _ (a tsserver plugin can register those). Extensions for content-mapped languages need this, because several commands accept only TypeScript and JavaScript files.

The TypeScript 7 extension has no equivalent. The object its activate returns offers registerContentMappers, onLanguageServerInitialized and initializeAPIConnection (the native API, not the language server's requests), and no command forwards a request to tsc --lsp.

Use cases

From TSRX (.tsrx files, served through a content mapper):

Feature VS Code's TypeScript (5.9 or 6) TypeScript 7
Go to Source Definition TSRX's command sends findSourceDefinition through typescript.tsserverRequest (as a _tsrx: request that its tsserver plugin registers), and it works in .tsrx files tsc --lsp answers custom/textDocument/sourceDefinition for content-mapped files, but the extension's command accepts only TypeScript and JavaScript language IDs (#64576), and no other extension can send the request
Find File References same approach possible not implemented yet (#63806); once it is, TSRX needs a way to ask for it on a .tsrx file

With a way to send requests, an extension could offer these features for its own files without waiting for each command to accept content-mapped languages.

Suggestion

A way for an extension to send a request to tsc --lsp, for example:

  • sendRequest(method, params, token) on the API object, or
  • a typescript.native-preview.sendRequest command, like typescript.tsserverRequest.

It could be limited to documents of the content mappers that the calling extension registered with registerContentMappers, or to custom/* methods.

Found while adding TypeScript 7 support for .tsrx files (tsrx-org/tsrx#136).

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