typescript-plugin-util
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

typescript-plugin-util

Utilities for developing TypeScript Language Server Plugins

Install a Language Service Plugin easily:

Easy plugin installation

const serviceLanguageImplementation = { getApplicableRefactors, getEditsForRefactor }
export = pluginDefaultInitialize(pluginDefinition, (modules, info)=>{
 info.project.projectService.logger.info(`${PLUGIN_NAME} created!`
})

Instead of:

function init(modules: { typescript: typeof ts_module }) {
  function create(anInfo: ts_module.server.PluginCreateInfo) {
    info.project.projectService.logger.info(`${PLUGIN_NAME} created`)
    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)
    }
    proxy.getApplicableRefactors = getApplicableRefactors
    proxy.getEditsForRefactor = getEditsForRefactor
    return proxy
  }
  return { create }
}
export = init

API docs

See apidocs

TODO

Package Sidebar

Install

npm i typescript-plugin-util

Weekly Downloads

1,025

Version

1.0.16

License

MIT

Unpacked Size

12.2 kB

Total Files

12

Last publish

Collaborators

  • cancerberosgx