question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add plugins property on TS Server open request

See original GitHub issue

Problem

VSCode allows TSServer plugin extensions to register themselves for language modes besides javascript and typescript. The angular extension for example can register the angular TSServer plugin for the ng-html language. When an ng-html file is sent to TS and the angular plugin is not active, Typescript will treat the file contents as typescript code, resulting in a number of syntax errors

Proposal

Add an optional plugins property on TSServer open requests.

interface OpenRequestArgs {
    ...,
    plugins?: string[]
}

plugins would be a list of tsserver plugin package identifiers.

On the TypeScript side, the new logic for handling the plugins property on open requests would look something like:

  • If plugins is undefined, the open request behaves the same as it does currently.
  • If plugins is an array, TypeScript checks to see if any of the plugins it has loaded are in the plugins.
    • When no match is found, the opened file is ignored by the TSServer
    • If a match is found, the opened file is handled by TypeScript. The plugin would be responsible for disabling the standard TS features in the file

Open Questions

What does ignoring a file mean? What happens when plugins is provided but no match is found against the loaded plugins on the TSServer? Two options I see:

  1. TS keeps the file open and VSCode continues sending update events about it, but TS never actually generate any events or fufills any requests against it.

  2. TS tells VSCode that it doesn’t care about this file, perhaps by returning an error from open VSCode would no longer send sync events about the file or send TS requests about it

scriptKindName OpenRequestArgs includes an optional field scriptKindName?: ScriptKindName.

type ScriptKindName = "TS" | "JS" | "TSX" | "JSX";

Should a new kind for external files be added?

type ScriptKindName = "TS" | "JS" | "TSX" | "JSX" | "EXTERNAL";

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
cyrilletuzicommented, Nov 19, 2018

Just to mention, as @mjbvz recommended me to, it’s still a need for tools like Angular Language Service (see cyrilletuzi/vscode-typescript-angular-plugin#1).

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS Server: Add way for plugins to provided additional ... - GitHub
Problem TS Server plugins sometimes want to provide additional metadata on responses beyond that found in the official TS Server API.
Read more >
Creating Apollo Server plugins - Apollo GraphQL Docs
You can create your own Apollo Server plugins to perform custom ... log the GraphQL query string associated with each request that's sent...
Read more >
TypeScript - Fastify
A plugin can be a set of routes, a server decorator or whatever. To activate plugins, use the fastify.register() method. When creating plugins...
Read more >
Typescript/Hapi: Property 'example' does not exist on type ...
I can see that the plugin is exposed in a route handler, however when I try to access that value using: async handler(request:...
Read more >
Language Server Extension Guide - Visual Studio Code
Get the extension using the {publisher.name}.{extensionId} , as defined in package.json . Open the specified document, and show it in the active text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found