Tools and Packages, that’s what I want!

Seeing that it’s been a great while since my last write-up for The Pattern, I thought I would share with you today’s endeavor: getting the right stuff in place so I can start coding in TypeScript. Now, I’m not going to write about the language, nor why its existence is a good thing. I might come back to those rants some other time. Also, that’s why TypeScript is not mentioned at all in the title for this post. I want to look at the tools, and specifically, how to get a development environment up and running.

My goal this afternoon was:

  1. be able to compile TypeScript
  2. write TypeScript (.ts) files in Sublime Text, hopefully with some nice syntax highlighting

Those who know me will tell you that, “Yes, sure! Peter does his development in Visual Studio, enjoying some additional bells and whistles, mind you.” So why not go for the TypeScript plugin for VS? That would be great, and I’ll probably try that next. Truth is, I need something that works with a simple text editor, and my current choice outside of Visual Studio is Sublime. And… it is something outside the comfort zone of the cozy, friendly environment that is Visual Studio. Stepping out of your comfort zone once in a while is a good thing, right?

Getting TypeScript to compile

I have one stimpack for you here. What you need is Chocolatey. Haven’t got it yet? Three words for you:

Install. It. Now.

And don’t come back until it is installed!

Back? Right. On a command line, type cinst typescript and watch your system get imbued with both the typescript compiler and node.js, which typescript happen to depend on. Dead simple. I told you, Chocolatey is what you need. It is magic.

I’m now set up to compile .ts files. On any command line I can type “tsc myfancyscript.ts” and I will get a message saying: Error reading file “myfancyscript.ts”: File not found…

Now on to enable writing that script before I embarrass myself even more.

Rigging Sublime

Inspired by the sweet choco-package-manager for tools, I was happy to find a package manager for Sublime packages too. With that in place, hit Ctrl+Shift+P to bring up the command interface, type “install” and hit the install package command. In the following dialog, enter “typescript” and find the “TypeScript language support for SublimeText2” package. Now we’ve got nice syntax highlighting.

Conclusion

As promised, not so much a post about the TypeScript language, more about how to get stuff in place. Chocolatey has proved to be a great bootstrapper for getting tools installed, taking care of versions, dependencies and updates. Also, Sublime as a text editor turns out to be quite powerful while still being fast and lightweight. The built-in support for packages has sparked a growing community creating support for new file formats and tools. Like TypeScript.

Happy coding!

Share

Author: Peter

Hi, my name is Peter Lillevold. I currently live with my two kids in eastern Norway in a small town called Askim. This blog is an outlet for technical articles on software development endavours. Thanks for stopping by, hope you find something useful!