Install the typescript definition manager

Create the tsd.json config file, which will store installed typings and configuration for tsd:

tsd init

When using git as source control, open up the .gitignore and add the typings path. We don't want the typings in source control, because we can retrieve them by performing tsd install.

Install the following 2 definitions (they are required to get working Aurelia definition files)

tsd install core-js --save
tsd install whatwg-fetch --save

Requires small modification :-(

The core-js lib contains the Promise definition and the es6-promises definition contains it, this gives build errors about being defined twice.

Open up the typings folder and remove the folder es6-promise and open the file whatwg-fetch\whatwg-fetch.d.ts and replace the es6-promise reference with /// <reference path="../core-js/core-js.d.ts" />. And remove the reference to /// <reference path="es6-promise/es6-promise.d.ts" /> from the typings\tsd.d.ts file.

In the build-system task, replace the line .pipe(to5(assign({}, compilerOptions, {modules:'system'}))) with .pipe(ts(tsProject)) to compile typescript code, instead of running Babel to compile the ES-* JavaScript code.

Running this will still give some errors, because we didn't include any TypeScript definition files (d.ts) for the files we don't own/ 3rd party libraries. Fix them by including the typescript definitions from Aurelia that are placed in the jspm folder and the typings we've installed from DefinitelyTyped by modifing the following lines (still in the file build\tasks\build.js):

Fixing the build errors

Core-js not having a default export

Open up jspm_packages\github\aurelia\fetch-client@0.2.0\aurelia-fetch-client.d.ts and replace import 'core-js' with import * as core from 'core-js' and add the following to remove most of the typescript warnings:

I have no clue what they are, so just added interfaces for them in the definition:

interface BufferSource {}
interface URLSearchParams {}

Next fix the same core-js issue in the bootstrapper file:
Open up jspm_packages\github\aurelia\bootstrapper@0.17.0\aurelia-bootstrapper.d.ts and replace import core from 'core-js'; with import * as core from 'core-js';

TsLint instead of JsLint

JsLint is the static code analysis tool for JavaScript files used in the build script. We would probably focus more on building Typescript code (because our JavaScript is generated). The TsLint build task solves this requirement for you, it's static code analysis for TypeScript code).