Skip to content

Gulp plugin for angularjs-ts-class-annotate - the AngularJS Typescript class-only annotation library

License

Notifications You must be signed in to change notification settings

yrtimiD/gulp-angularjs-ts-class-annotate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-angularjs-ts-class-annotate

Gulp plugin which adds AngularJS dependency annotation for Typescript classes

Internally uses angularjs-ts-class-annotate library.

Important notes and limitations

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

Motivation

  • Do not write code which may be automatically generated
  • Makes typescript files ready for uglification after compiling to js

Usage example

npm install --save-dev gulp-angularjs-ts-class-annotate

typescript@3 is a peer dependency, make sure to install it (if not have already):

npm install --save-dev typescript@3
const gulp = require("gulp");
const ngAnnotate = require("gulp-angularjs-ts-class-annotate");

gulp.task("annotate", function () {
	return gulp.src("./src/**/*.ts")
		.pipe(ngAnnotate())
		.pipe(gulp.dest("annotated"));
});

After running gulp task, original typescript file

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

will be saved as:

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

Full usage demo can be seeing here.

Building locally

npm install
npm install typescript@3 --no-save
npm run demo

About

Gulp plugin for angularjs-ts-class-annotate - the AngularJS Typescript class-only annotation library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published