Skip to content

Extension API Request: Send Custom Requests To TypeScript Language Service Plugins #43893 #218275

@hediet

Description

@hediet

(Follow-up of microsoft/TypeScript#43893)

TypeScript language server plugins can now register handlers of custom commands (this is used for the VS Code inlien value provider for example).

However, VS Code extensions still cannot send such commands to the TypeScript language server.

It would be nice if the VS Code TypeScript extension would expose API to do that.

Proposed Solution

Extend the API returned by the TypeScript language features extension:

class ApiV0 {
  // ...
  invokeCustomCommand(customCommandId: string, uris: Uri[], payload: /* JSON serializable */ unknown): Promise<unknown> { ... }
}

Uris are automatically translated to file names to make life of third party extensions much easier (VS Code extensions only use Uris, typescript language service plugins use only file names).

This would then enable typescript language service plugins to react to such a command and send some data back:

export = function init(modules: { typescript: typeof ts }) {
	return {
		create(info: ts.server.PluginCreateInfo): ts.LanguageService {
			info.session?.addProtocolHandler('getRelativeFileCall', request => {
				return {
					response: {  myData: { ... } }
				};
			});
			return info.languageService;
               }
       }
}

Metadata

Metadata

Assignees

Labels

apifeature-requestRequest for new features or functionalitytypescriptTypescript support issuesverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions