bitwix

Tangential comments about Software Development

Wednesday, February 27, 2013

TypeScript brings C# values to JavaScript

I ported my jQuery mobile web app to TypeScript www.typescriptlang.org which took an afternoon to get my head around, then a morning to do.

You quickly get used to refence path= at the top, so that you get Intellisense.

I tried renaming all files as .ts and compiling. That created too many errors. So I brought in code files one at a time, with judicious commenting-out. That worked.

It's nice to be able to choose when to give a variable a type, when to use any and when not to set the type. I found myself tightening (typening?) the code a little as I went on, but have stopped well short of 100% typed.

Compile errors as a spell check: so useful, so familiar! Intellisense as a shortcut to avoiding spelling errors in the first place: brilliant!

Then compile errors during aggressive refactoring, as I move functionality between modules. I like the reassurance that I've changed all references.

It's the certainty of the compile step that I value. By giving that back to me, TypeScript is a significant improvement on JavaScript.