The Official Ionic Blog

Build amazing native and progressive web apps with HTML5

Hey everyone, long time no see!

In our last two screencasts, we created a simple TypeScript build process and looked at adding typings to our code. Let’s pick up where we left off and convert our controllers to something more ES6 class-like.

Getting Up To Date

$ git clone https://github.com/driftyco/ionic-typescript-example.git && cd ionic-typescript-example
$ npm install && tsd install

Additional Notes

Additional videos

Ionic and TypeScript Part 1

Ionic and TypeScript Part 2

Ionic and TypeScript Part 4

  • tkgreg

    It looks really cool, is it reasonable to start a new Ionic project with the TypeScript or it’s just experimental stuff?

    • Mike Hartington

      Definitely, typescript is a solid options for ionic 1 projects looking to make sure they can upgrade to v2

  • Kaos

    It could start to use typescript with Ionic for sure.

  • Marçal Juan Llaó

    Which is the difference between using “public $inject = […]” and use “// @ngInject” above constructor? I’m using ngInject. Thanks!

    • Mike Hartington

      They do the same thing. personally I like using $inject but if it works the same, then you could do that as well.

  • Martin Tomov

    Hi Mike, what plugins do you use for your zsh terminal? Looks awesome! Hope that they will be linux available..

  • KIRA YAGAMI ARIZPE

    I have a question: How Integrate ngCordva with Typescript TSD, for example how use $window.Media Plugin, if when i try window.cordova.plugins only have Keyboard or i need $cordovaGeolocation , exist ICordovaGeolocation ?

  • Edgar Kuskov

    Instead of creating this $inject string, you can use the “gulp-ng-annotate” and then you don’t need to use $inject, as it finds the injections automatically without problems.

  • Seika85

    I get:

    [tsc] > src/controllers.tsx(30,44): error TS2339: Property ‘chatId’ does not exist on type ‘IStateParamsService’.
    Failed to compile TypeScript: Error: tsc command has exited with code:2

    So your code does not compile on my end…