/// <reference path="./typings/bundle.d.ts" />

import {task, src, dest, watch} from 'gulp';
import * as ts from 'gulp-typescript';
import * as tslint from 'gulp-tslint';
import * as babel from 'gulp-babel';

task('build', ['build:ts']);

const project = ts.createProject('tsconfig.json', {
	typescript: require('typescript')
});

function buildTypeScript(): ts.CompilationStream {
	return project.src().pipe(ts(project));
}

task('build:ts', () =>
	buildTypeScript()
		.pipe(babel())
		.pipe(dest('./built'))
);

task('lint', () =>
	src('./src/**/*.ts')
		.pipe(tslint({
			tslint: require('tslint')
		}))
		.pipe(tslint.report('verbose'))
);

task('test', ['build', 'lint']);

task('watch', ['build'], () =>
	watch('./src/**/*.ts', ['build:ts'])
);

/// <reference path="./typings/bundle.d.ts" />

import {task, src, dest, watch} from 'gulp';
import * as ts from 'gulp-typescript';
import * as tslint from 'gulp-tslint';
import * as babel from 'gulp-babel';

task('build', ['build:ts']);

function buildTypeScript(): ts.CompilationStream {
	const project = ts.createProject('tsconfig.json', {
		typescript: require('typescript')
	});

	return project.src().pipe(ts(project));
}

task('build:ts', () =>
	buildTypeScript()
		.pipe(babel())
		.pipe(dest('./built'))
);

task('lint', () =>
	src('./src/**/*.ts')
		.pipe(tslint({
			tslint: require('tslint')
		}))
		.pipe(tslint.report('verbose'))
);

task('test', ['build', 'lint']);

task('watch', ['build'], () =>
	watch('./src/**/*.ts', ['build:ts'])
);

--- 
+++ 
@@ -7,11 +7,11 @@
 
 task('build', ['build:ts']);
 
+const project = ts.createProject('tsconfig.json', {
+	typescript: require('typescript')
+});
+
 function buildTypeScript(): ts.CompilationStream {
-	const project = ts.createProject('tsconfig.json', {
-		typescript: require('typescript')
-	});
-
 	return project.src().pipe(ts(project));
 }
 
Create project object before running tasks
