typescript-plugin-extract-interface

1.0.6 • Public • Published

typescript-plugin-extract-interface

A TypeScript Language Server Plugin to extract an interface from an existing class.

Tested:

  • generic parameters,
  • methods, properties, constructor
  • static, protected and private methods won't appear

extract interface screen cast WIP

How to use:

npm i --save-dev typescript-plugin-extract-interface

in your tsconfig.json, add the plugin:

{
  "compilerOptions": {
    "plugins": [{
        "name": "typescript-plugin-extract-interface"
    }]
  }
}

Make sure you have installed typescript in your project (npm i --save-dev typescript) the editor you are using uses that typescript and not another. For example, Visual Studio Code comes with its own typescript version, so you need to "Select TypeScript Version" of the workspace:

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

In Atom editor, if you use atom-typescript package you don't need to do anything since by default it will use the workspace's TypeScript version.

ISSUES / TODOS

  • can use this to format : https://www.npmjs.com/package/code-block-writer
  • make the class implement the interface at the end
  • if the class already implements an interface, we shouldn't extract those methods.
  • what about methods of super classes ? this behavior could be configurable
  • put the interface in a separate file and add an import?
  • fix format
  • feature, if user selects only some methods, we should only extract those.
  • good enhancement: i just finish writting a class . at last I add "implements SomeName" . Because the interface doesn't exist, would be super if the plugin suggest me there a refactor for creating / extracting it

Package Sidebar

Install

npm i typescript-plugin-extract-interface

Weekly Downloads

7

Version

1.0.6

License

MIT

Unpacked Size

22.1 kB

Total Files

8

Last publish

Collaborators

  • cancerberosgx