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).
VS Code's built-in TypeScript extension lets other extensions send requests to its server with the
typescript.tsserverRequestcommand: 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
activatereturns offersregisterContentMappers,onLanguageServerInitializedandinitializeAPIConnection(the native API, not the language server's requests), and no command forwards a request totsc --lsp.Use cases
From TSRX (
.tsrxfiles, served through a content mapper):findSourceDefinitionthroughtypescript.tsserverRequest(as a_tsrx:request that its tsserver plugin registers), and it works in.tsrxfilestsc --lspanswerscustom/textDocument/sourceDefinitionfor content-mapped files, but the extension's command accepts only TypeScript and JavaScript language IDs (#64576), and no other extension can send the request.tsrxfileWith 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, ortypescript.native-preview.sendRequestcommand, liketypescript.tsserverRequest.It could be limited to documents of the content mappers that the calling extension registered with
registerContentMappers, or tocustom/*methods.Found while adding TypeScript 7 support for
.tsrxfiles (tsrx-org/tsrx#136).