Rory's Blog
Home
Blog
Projects
Facebook
Google+
Github
RSS

TypeScript: Quick Try

11/16/15

I made a thing with Crafty, but in TypeScript this time.

Can you say "best game yet?".

....

No?

Well, it should be the last filler game, I swear. I need to buckle down and prepare for the Game Jam this weekend.

Anyways, I've started messing with TypeScript. Verdict so far? I like it a lot actually.

It's kind of interesting, there's this period of time where programmers seem to tire of telling the computer everything it should expect, and that's why dynamic languages are around (kinda). And then there's this period of time where I wish the computer will tell me everything it can to warn me if I'm doing something stupid that the computer is better at noticing than me.

TypeScript has this perfect sort of balance. It'll warn me about the red flags it's noticed, and then go right along compiling the javascript as it'll run.

Like, if the ts file is just javascript, it'll warn me about how nothing is typed, and then give me a js file with that exact same javascript.

Meaning I can take advantage of the dynamic nature of javascript when I feel like it, and have a helpful system help me clean it up when I want things more rigourously defined/designed.

Another cool thing is that I can take any regular javascript library I want to use, and make a type definitions file for it so the typescript code I wrote doesn't throw any warnings about interfacing with that library.

If I wait until the compiler warns me about my misunderstood connection to whatever javascript library (currently craftyjs), then I can know exactly what bits of a library I want to properly understand and avoid the tendency to jump into wasting a bunch of time researching a library before trying to use it for anything.

I think I'll continue messing with this language for a bit.