kabuku / ts-ng-annotate

Add and fix dependency annotations of AngularJS on TypeScript files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ts-ng-annotate

ts-ng-annotate adds and fixes dependency annotations of AngularJS on TypeScript files.

Getting Started

The following steps add and fix annotations in place:

git clone https://github.com/kabuku/ts-ng-annotate.git
cd ts-ng-annotate
npm install
./node_modules/.bin/ts-node ts-ng-annotate-main.ts /path/to/ts-file...

Supported code

ts-ng-annotate supports the following code:

  • Inline function like argument of angular.Module method call which follows AngularJS Style Guide (Definitions (aka Setters))
  • Function like expression which has 'ngInject' prologue
  • Constructor which has 'ngInject' prologue

where function like means function expression or arrow function.

Examples

Inline arrow function

// Before
angular.module('myapp').factory('MyService', ($http) => {});

// After
angular.module('myapp').factory('MyService', ['$http', ($http) => {}]);

Constructor

// Before
class MyService {
    constructor($http) {
        'ngInject';
    }
}

// After
class MyService {
    static $inject = ['$http'];
    constructor($http) {
        'ngInject';
    }
}

License

MIT

About

Add and fix dependency annotations of AngularJS on TypeScript files

License:MIT License


Languages

Language:TypeScript 100.0%