gulp plugin to append class name & constructor parameter names to TypeScript Class. If typesafe option is true, this plugin append $inject from constructor parameter type.
Working with TypeScript 1.5 Decorator, we can write component-based programing code for AngularJS.
let Controller = (clazz:any)=>{
angular.module('sample')
.controller(clazz.$className,class);
}
@Controller
class TestController{
date:Date;
constructor(public q:angular.IQService){
this.date = new Date();
}
}
gulp-typescript-annotate append $className and $inject to code.
let Controller = (clazz:any)=>{
angular.module('sample')
.controller(clazz.$className,class);
}
@Controller
class TestController{
date:Date;
constructor(public q:angular.IQService){
this.date = new Date();
}/*<generated>*/static $className = 'TestController';static $inject = ['$q'];/*</generated>*/
}
Install with npm
$ npm install gulp-typescript-annotate
Add gulp-typescript-annotate plugin to gulp pipe before gulp-typescript plugin.
var gulp = require('gulp');
var typescript = require('gulp-typescript');
var typescriptAnnotate = require('gulp-typescript-annotate');
gulp.task('scripts', function () {
return gulp.src('./**/*.ts')
.pipe(typescriptAnnotate({typesafe:true}))
.pipe(typescript())
.pipe(gulp.dest('./dist'));
});