Generate Typescript Pages?

Hey guys,

Just started learning Ionic 2 and Angular 2, so much new stuff to grasp with typescript!

I’m trying to use the command line to generate new pages for my project, using the code below:
ionic g page myPage

However, the generated pages are based on regular old js, no ts! I tried adding “–ts” to the end of the command, just like I did when I generated the project but no dice.

Is there a way to use the page generate command that exports typescript instead of javascript?

Well, from what I understand, “regular” Javacript (ES6) really is Typescript, since Typescript is a pure superset of Javascript. So any piece of valid Javascript is also valid Typescript (but not the other way around).

So, this may be a silly answer (or a matter of semantics) but in fact the commands did generate Typescript code. After that it’s up to you to start adding/using as many Typescript specific features as you like.

There is even an argument to be made for starting out with regular ES6 and then gradually moving to TS.

P.S. the only real issue would be that the generated files end in “.js” and you would have to rename them manually to “.ts”

Just don’t use the generator. Create files manually.

This is something we’re planning on adding soon!


Renaming the files to “.ts” is basically what I’ve started doing. Also, the class definition has a bunch of code that isn’t needed for the typescript implementation so I just clear that out as well.