GithubHelp home page GithubHelp logo

matb / gulp-typescript-annotate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from takeshi/gulp-typescript-annotate

0.0 2.0 0.0 250 KB

Home Page: https://www.npmjs.com/package/gulp-typescript-annotate

JavaScript 63.18% TypeScript 24.91% HTML 11.38% CSS 0.53%

gulp-typescript-annotate's Introduction

gulp-typescript-annotate

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.

Motivation

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

Install with npm

$ npm install gulp-typescript-annotate

Usage

Modify gulpfile.js

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'));
});

Options

forceLowerCase

By default injected type names use the same casing as the parameter name in the constructor. If you want to have all types starting with lowercase, set forceLowerCase: true.

gulp-typescript-annotate's People

Contributors

matthiasmurray avatar takeshi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.