leob/ionic-quickstarter

Use type definition files to provide design time intellisense

Closed this issue · 2 comments

This project is written in JavaScript, but there are some ways to use TypeScript "type definition files" to provide design time intellisense (i.e. coding hints and errors if you mistyped something) during coding. This makes it easier to code without having to constantly look at docs for various libraries and find typos later in the browser console.

TypeScript is a Microsoft thing, but open source and is being widely adoption. For example, Angular 2.0 is based on TypeScript. Of course, ionic is heavily dependent on Angular so adding TypeScript incrementally should all feel "natural" for this project. Note that I am not suggesting we move to TypeScript as a development language... keep that JavaScript. Just use TypeScript definition files to "help" at design and compile time.

There are two benefits to doing this:

  1. Design time "intellisense". When coding, you get hints on what to do, and red squiggly lines if you have a typo. For people used to typed languages, this is valuable.
  2. Compile time checks. When compiling, you could use the type definition files to generate "errors" if there are typos in code. This is not required and design time is fine for now, but over time you might want to do the full compile time checks to reduce errors due to typos.

For the first one, i.e. design time intenseness, it depends on what IDE people use and whether that IDE supports TypeScript definition files. I did some research and it seems adoption is decent.

For example:

  1. Visual Studio Code (this is what I use, available for free on Mac or PC): http://blogs.msdn.com/b/vscode/archive/2015/06/05/mobile-hybrid-apps-with-vs-code-and-ionic.aspx
  2. IntelliJ/WebStorm (this is what you use, I believe): https://www.jetbrains.com/webstorm/help/typescript-support.html (especially note "stubs for TypeScript definition files")
  3. Sublime: https://cmatskas.com/getting-started-with-typescript-and-sublime-text/

For now, I think we can just include the type definition files in the project (via the DefinitelyTyped project) so that IDE's that support this can show intenseness at design time. No change at runtime or build time. Later, if you want, I can add this to the build step so you can "compile errors" if you have a typo in your code... rather than finding out at runtime. So the second benefit can wait for now.

leob commented

Hey that's cool, by all means please go ahead and include them. And the compile time thing, yeah sure if it's beneficial.

I really see that having someone else on board brings new and fresh ideas, that's great. It's totally impossible for a single person to know everything nowadays (if it ever was).

Yes, I'm using IntelliJ/Webstorm as my IDE so that's nice if I can also benefit from it.

Probably there's a lot more I could get out of Webstorm and all kind of other tools because after toiling away today I have the feeling that I'm doing too much manual labor. Even though Ionic is great but still it's a lot of work to create anything moderately complex.

Productivity (at least mine) isn't as good as I think it could be.

So yeah as a first step let's definitely include the typing files.

leob commented

Okay, merged your PR so I'm closing this issue. Maybe the only thing that would be nice is some docs on the Wiki on how to use this stuff. Like I said I need to dive into how to use it in IntelliJ/Webstorm and when I know how to do it I could write a small manual about it on the Wiki.