Unexpected token


Hello fellow ionites!!! Just started working on Ionic2, it looks pretty simple, but don’t why I keep getting this error “Unexpected Token”, when I try initializing NavController.

import {NavController,Page} from 'ionic-angular';
import {Friend} from '../friends/friends';

 templateUrl: 'build/pages/stack/stack.html'

export class Stack {
 constructor(nav: NavController) { //Unexpected token, what could go wrong???
     this.nav = nav;

 friends() {


TypeScript or EcmaScript 6?


TypeScript (Javascript), @mauricionarcizo do you have any idea of what i’m not doing right?


Try declare your NavController as public:

constructor(public nav: NavController) {

But I’m not sure if is this problem. Show complete error.


Most probably you started the project as JavaScript (which is currently the default).

To start a project with TypeScript support you should use the following command:

ionic start MyApp --v2 --ts

Or if you want to convert your current project to TypeScript check out [the linked post]
(Ionic 2 not recognize typescript gramma):


Thank you @mauricionarcizo and @iignatov, let me try it out, will get back to you guys.

Thanks once again.