Sublime Forum

Typescript auto import plugin

#1

I am working with the new angular 2 beta, and I am getting to love typescript. However, there has been one thing to really annoy me and that is having to constantly go to the top of the page and do an import statement.

ex: Take notice of the 1) and 2)

import {OnInit} from 'angular2/core';// <---- 2) I WOULD LIKE A PLUGIN THAT WILL DO THIS!

export class TestComponent implements OnInit // <-- 1) ONCE I TYPE THIS {
    ngOnInit(): any {
    }
}

I have seen this implemented in a text editor I assume was webstorm (It was in the Mindspace video tutorials for angular2 on youtube), but I would like to know if there are any plugins available or anyone willing to create such plugin for Sublime Text 3 that can have the same features.

I notice that the webstorm plugin had these features:

  • it would create the import statement when it detected a component from another file to be imported
  • it would include the source to that file when the import statement was added
0 Likes

#2

Not sure it works for typescript but there is package doing a similar function for javascript: https://packagecontrol.io/packages/ImportJS
And if it does not work, maybe this can be a good starting point to write the plugin yourself

0 Likes