angularjs-ts-class-annotate
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

angularjs-ts-class-annotate

Adds AngularJS dependency annotations for typescript classes

Important notes

  • Supports typescript classes only.
  • Adds AngularJS $inject statement for constructors in all classes regardless if they are registered in the angular injector or not.
  • Existing $inject statements are totally ignored.

Usage example

npm install angularjs-ts-class-annotate

typescript is a peer dependency, make sure to install it (tested with v3 only):

npm install typescript@3

and run:

const fs = require("fs");
const annotateTs = require("angularjs-ts-class-annotate");
 
var fileContent = fs.readFileSync("some-class.ts", "utf8");
fileContent = annotateTs(fileContent);
fs.writeFileSync("some-class.annotated.ts", fileContent, "utf8");

Before: original some-class.ts

class Class1 {
    constructor(private $log: ng.ILogService, private $window: ng.IWindowService) {
    }
}

After: annotated some-class.annotated.ts

class Class1 {
static $inject = ["$log","$window"];
    constructor(private $log: ng.ILogService, private $window: ng.IWindowService) {
    }
}

Building

npm i
npm run build
npm run demo

Package Sidebar

Install

npm i angularjs-ts-class-annotate

Weekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

19.5 kB

Total Files

13

Last publish

Collaborators

  • yrtimid