diff --git a/gulpfile.js b/gulpfile.js index 250f3247fe..c9f3e6d2d5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,6 +20,7 @@ var exec = require('child_process').exec; var babel = require('gulp-babel'); var traceur = require('gulp-traceur'); var webpack = require('gulp-webpack'); +var tsc = require('gulp-typescript'); var lazypipe = require('lazypipe'); var cache = require('gulp-cached'); var connect = require('gulp-connect'); @@ -59,7 +60,7 @@ gulp.task('watch', function() { 'serve', function() { - watch(['ionic/**/*.js', '!ionic/components/*/test/**/*'], function() { + watch(['ionic/**/*.js', 'ionic/**/*.ts', '!ionic/components/*/test/**/*'], function() { runSequence( 'transpile', 'bundle.js', @@ -92,7 +93,7 @@ var traceurOptions = { annotations: true, types: true, outputLanguage: 'es6' -} +}; var babelOptions = { optional: ['es7.decorators'], @@ -122,14 +123,32 @@ var exampleBabelOptions = { } }; +var tscOptions = { + target: 'ES6', + // Don't use the version of typescript that gulp-typescript depends on, we need 1.5 + // see https://github.com/ivogabe/gulp-typescript#typescript-version + typescript: require('typescript'), + allowNonTsExtensions: true, + isolatedModules: true, + //declaration: true, //generate d.ts files + emitDecoratorMetadata: true, + experimentalDecorators: true, + noEmitOnError: false, // ignore errors + rootDir: '.' +} + gulp.task('transpile', function() { - return gulp.src(['ionic/**/*.js', '!ionic/components/*/test/**/*', '!ionic/init.js']) + var stream = gulp.src(['ionic/**/*.ts', 'ionic/**/*.js', '!ionic/components/*/test/**/*', '!ionic/init.js']) .pipe(cache('transpile', { optimizeMemory: true })) - .pipe(traceur(traceurOptions)) - .on('error', function (err) { - console.log("ERROR: " + err.message); - this.emit('end'); - }) + .pipe(tsc(tscOptions, null, tsc.reporter.nullReporter())) + // .on('error', function(error) { + // stream.emit('error', error); + // }) + // .pipe(traceur(traceurOptions)) + // .on('error', function (err) { + // console.log("ERROR: " + err.message); + // this.emit('end'); + // }) .pipe(gulp.dest('dist/js/es6/ionic')) .pipe(babel(babelOptions)) .on('error', function (err) { @@ -137,6 +156,8 @@ gulp.task('transpile', function() { this.emit('end'); }) .pipe(gulp.dest('dist/js/es5/ionic')) + + return stream; }); gulp.task('bundle.js', function() { @@ -166,18 +187,19 @@ gulp.task('bundle.js', function() { gulp.task('examples', function() { var buildTest = lazypipe() - .pipe(traceur, traceurOptions) + //.pipe(traceur, traceurOptions) + .pipe(tsc, tscOptions, null, tsc.reporter.nullReporter()) .pipe(babel, exampleBabelOptions) // Get each test folder with gulp.src return gulp.src('ionic/components/*/test/*/**/*') .pipe(cache('examples', { optimizeMemory: true })) - .pipe(gulpif(/.js$/, buildTest())) + .pipe(gulpif(/.ts$/, buildTest())) .on('error', function (err) { console.log("ERROR: " + err.message); this.emit('end'); }) - .pipe(gulpif(/index.js$/, createIndexHTML())) + .pipe(gulpif(/index.js$/, createIndexHTML())) //TSC changes .ts to .js .pipe(rename(function(file) { file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep) })) diff --git a/ionic/animations/animation.js b/ionic/animations/animation.ts similarity index 100% rename from ionic/animations/animation.js rename to ionic/animations/animation.ts diff --git a/ionic/animations/builtins.js b/ionic/animations/builtins.ts similarity index 100% rename from ionic/animations/builtins.js rename to ionic/animations/builtins.ts diff --git a/ionic/components.js b/ionic/components.ts similarity index 100% rename from ionic/components.js rename to ionic/components.ts diff --git a/ionic/components/action-menu/action-menu.js b/ionic/components/action-menu/action-menu.ts similarity index 58% rename from ionic/components/action-menu/action-menu.js rename to ionic/components/action-menu/action-menu.ts index db2175bbfc..202b2c5977 100644 --- a/ionic/components/action-menu/action-menu.js +++ b/ionic/components/action-menu/action-menu.ts @@ -6,79 +6,59 @@ * The ActionMenu is a modal menu with options to select based on an action. */ -import {NgIf, NgFor} from 'angular2/angular2'; -import {View} from 'angular2/src/core/annotations_impl/view'; -import {Injectable} from 'angular2/di'; +import {View, Injectable, NgFor, NgIf} from 'angular2/angular2'; -import {Icon} from 'ionic/ionic'; import {IonicApp} from '../app/app'; +import {Overlay} from '../overlay/overlay'; +import {Animation} from '../../animations/animation'; import * as util from 'ionic/util'; -import {Overlay} from '../overlay/overlay'; -import {IonicComponent} from '../../config/annotations'; -import {Animation} from 'ionic/animations/animation'; - -@IonicComponent(ActionMenu) @View({ template: ` -
+You\'re pretty awesome