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.

The sample given at for `Writing-a-Language-Service-Plugin` doesn't compile.

See original GitHub issue

Bug Report

🔎 Search Terms

plugin language-service compile

  • I was unable to test this on prior versions because there are no earlier versions of the documentation_____

💻 Code

This is copied from the guide at https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin

  const ts = modules.typescript;

  function create(info: ts.server.PluginCreateInfo) {
    // Set up decorator
    const proxy: ts.LanguageService = Object.create(null);
    for (let k of Object.keys(info.languageService) as Array<
      keyof ts.LanguageService
    >) {
      const x = info.languageService[k];
      proxy[k] = (...args: Array<{}>) => x.apply(info.languageService, args);
    }
    return proxy;
  }

  return { create };
}

🙁 Actual behavior

I am entering the code sample from https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin and I am getting compile errors while setting up the decorator:

image

🙂 Expected behavior

I was hoping I could copy/paste the sample and it would work.

NOTE: It’s also possible the documentation around this just needs to be clearer. How do you go about starting the plugin? Do you run yo code? Do you run npm init? Do you just create a single file index.js? I am very unclear how to begin development of this plugin.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ortacommented, Sep 27, 2021

That code sample goes in your package.json and the tsconfig would have "my-plugin"

1reaction
ortacommented, Sep 24, 2021

Cool! I’ve updated the code on the wiki page (and you’re welcome to update it too, https://github.com/microsoft/TypeScript-wiki/blob/main/Writing-a-Language-Service-Plugin.md ) to handle strict: true which should remove the compiler errors.

The system is very simple - you give the tsconfig.json a node-style resolution path to the JavaScript file you’ve made, I thought the ‘testing locally’ section did a pretty good job covering that but I’m open to improvements

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing a Language Service Plugin · microsoft/TypeScript Wiki
Let's write a simple plugin. Our plugin will remove a user-configurable list of property names from the completion list. You might use this...
Read more >
How to write a Diagnostics TypeScript Language Service ...
A TypeScript Language Service Plugin can be used to change the editing experience for TypeScript users. It doesn't interfere with the compiler.
Read more >
java - Could not compile my first Maven project as provided in ...
The problem is the given package name package com.peter.2nd; which is not allowed becaue 2nd is not allowed.
Read more >
Apache Maven Compiler Plugin
org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile. Description: ... If debug is not turned on, this attribute will be ignored.
Read more >
Implementing Gradle plugins
Writing plugin code is a routine activity for advanced build authors. ... The custom task is provided by a plugin that takes care...
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