リポジトリ準備
$ mkdir GulpTypeScript; cd GulpReactTypeScript
$ git init
$ npm init
$ npm install --save-dev gulp gulp-typescript
Gulpfile, index.html, index.tsを用意
gulpfile.js
'use strict';
var gulp = require('gulp');
var typescript = require('gulp-typescript');
gulp.task('build', function() {
gulp.src('index.ts').pipe(typescript()).pipe(gulp.dest('.'));
});
index.html
<html>
<head>
</head>
<body>
<section id="hello-world"></section>
<script src="index.js"></script>
</body>
</html>
index.ts
// TypeScriptで書く意味ないけど
var elem = document.getElementById('hello-world');
elem.innerHTML = 'Hello, world!';
確認
$ gulp build
$ open index.html