The Official Ionic Blog

Build amazing native and progressive web apps with HTML5

In our most recent screencast, we talked about future-proofing your app. We converted our JavaScript to TypeScript and created a simple build step to compile everything back. Now, let’s look at how we can use TypeScript’s static types to annotate our code. We’ll add definition files for Ionic and start getting code completion in our editor.

Adding TSD

$ sudo npm install -g tsd
$ tsd install ionic cordova --save

Reference the definition files

controller.ts

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

Additional Notes

Follow up videos

Ionic and TypeScript Part 1

Ionic and TypeScript Part 3

Ionic and TypeScript Part 4

In my next post we’ll walk through converting our controllers to something more class like.

  • soniyj

    Thanks for the tutorial, I was looking for something similar in order to move to ES6/Typescript.
    However, I followed the first and the second part, but I got some problems.

    First you need to install also cordova-ionic otherwise there is an error on Keyboard

    tsd install cordova-ionic –save

    Moreover after you run gulp compile, the reference will be into the js files as well.

  • http://batman-news.com bob

    What about Visual Studio? Will there be an ionic 2.0 project template?

  • Marçal Juan Llaó

    When part 3? 🙂 Can’t wait!

  • jetmiller

    found tsd-cordova plugs for device, inappbrowser, slashscreen and statusbar.
    but i need the plugs for whitelist, keyboard and console. where can i find them?

  • Bernardo Gomes

    THanks for this tutorial ! Great Job MAN !