microsoft / microsoft/TypeScript

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

Open
#45,915 15 comments 1 reaction 1 assignee View on GitHub

@orta is already working on this.

Since Sep 16, 2021.

Docs
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.