Using ES6 features with TypeScript

Published on September 18, 2015 in TypeScript · Read time 9 minutes

TypeScript is a transpiler The TypeScript compiler converts your code from TypeScript, which is a subset of JavaScript, to TypeScript. Compiler vs. Transpiler There is some confusion about the difference between a compiler and a transpiler. A compiler takes your code and turns it into something very different, a whole new language. A good example is with a high level language such as C# or Visual Basic. When you write code and build it, the compiler (either csc.exe C# compiler or vbc.exe Visual Basic compiler in this case) takes your code and turns it into Intermediate Language (IL). Example C# code; And the compiled code (as seen using ILDasm.exe); The above code is certainly not C#. The C# has been changed into a whole new language. A transpiler takes your code and changes it. But it’s still in the same language that you started out with. TypeScript is JavaScript, infact, TypeScript is a subset of JavaScript. When the TypeScript compiler runs over your code, it reads in TypeScript (which is JavaScript) and outputs JavaScript. The end resulting language is the same as what you started out with. The following TypeScript code is completely valid; And the resulting transpiled…

Getting started with TypeScript

Published on September 11, 2015 in TypeScript · Read time 6 minutes

This is the 101 tutorial which describes getting started with TypeScript using either the TypeScript Playground , Node.js or VS Code . At its simplest, TypeScript is a programming language that provides optional static typing for JavaScript. TypeScript is JavaScript. Any valid JavaScript is valid TypeScript. The beauty of TypeScript is that you can define types for your JavaScript variables and functions, and get compile time error checking and error reporting. This tutorial focuses on getting started with TypeScript and demostrates the basics to get up and running quickly. TypeScript Playground The quickest, easiest way to get started with using TypeScript is to experiment with the TypeScript playground . The TypeScript playground enables you to write TypeScript code in the browser, and see the resulting compiled JavaScript alongside. First things first, TypeScript doesn’t try to force you to write code in a particular style. In fact, you can write 100% pure JavaScript code in get the same code out at the other end. Try entering the following code in the TypeScript pane on the left; See the output? Identical. You can take advantage of TypeScript is much or as little as you…

Devs, this is how I got fit

Published on September 04, 2015 in Career · Read time 14 minutes

Right now, I’m in pretty good shape. I have the confidence to say this because I’ve worked very hard over the last 18 months to get to this point. I’m not a muscular person, like what you might see in a designer underwear advert…and this was never my personal goal, but I certainly don’t feel embarrassed anymore when I take my shirt off. I’ve discovered a few very simple patterns for losing weight, gaining muscle (at a slow rate) and generally feeling better about myself. This has been such a big success for me, that I felt it only right to share with you. I talk about myself a lot in this post, and I apologize for that, but it’s hard not to. I believe that if you follow this advice and these tips, you can achieve the same results as me. Backstory Poor diet, smoker, drinker, allergic to exercise guy Growing up as a teenager in North-West England, UK, in the early 2000’s, I was skinny. I had an extremely poor diet and frankly was “allergic” (not literally, just mentally) to vegetables and healthy food in general. I flat out refused to eat vegetables because I simply didn’t like them. For tea I would have “chips and something”, usually chicken, beef, pork, typically skins on and deep…

TypeScript Tips and Tricks

Published on August 28, 2015 in TypeScript · Read time 7 minutes

Automatically compile TypeScript files when using VS Code If you’re writing TypeScript using Visual Studio, your files are automatically compiled when you save (assuming you haven’t turned this off…the feature is found in the Project Properties > TypeScript Build screen). If you don’t use Visual Studio, and instead are using a lightweight IDE such as VS Code or Sublime Text , you don’t get this feature. Manual compilation First things first, how would you normally compile a TypeScript file to JavaScript? VS Code doesn’t do this out of the box (perhaps the will add this functionality in the future, I’m not sure). You use a task runner . To configure a task runner, open your project that has some TypeScript files, and press Ctrl + Shift + B . A little notification to appear that tells you that no task runner is configured. Click Configure Task Runner . VS Code will create a directory called .settings and add a new JSON file called tasks.json to this directory. Open tasks.json and inspect the default configuration (the one that isn’t commented out, VS Code will show you some other sample configurations that are commented out. Look for the following line; Change this…

ASP .NET 5 (vNext), first thoughts

Published on August 21, 2015 in C#, Career · Read time 4 minutes

Microsoft ASP .NET 5 is a major shift from traditional ASP .NET methodologies. Whilst I am not actively developing ASP .NET 5 applications at the minute, .NET has always been my bread and butter technology. When I look at industry trends here in the UK, all I see is .NET .NET .NET, therefore it is important to have one eye on the future. I’ve watched all the introduction videos on the ASP .NET website , but I also wanted to take a look at what ASP .NET 5 means to me . This is not meant to be a fully formed post. This will come later down the line. Right now, I think ASP .NET 5 is evolving too quickly to be “bloggable” fully. Version disambiguation and terminology Lets take a second to disambiguate some terminology. Microsoft’s understanding of versioning has always been different to everybody else. This tweet from Todd Motto really sums it up; Bill Gates on counting to ten. 1, 2, 3, 95, 98, NT, 2000, XP, Vista, 7, 8, 10. Todd Motto (@toddmotto) August 3, 2015 Looks like versioning is not going to get any simpler for the time being ASP .NET 5 (ASP .NET 4.6 is the current version) Previously known as ASP .NET vNext, ASP .NET 5 is the successor of ASP .NET 4.6 . In the past…