TypeScript - Visual Studio / MSBuild conditional compilation

Conditional Compilation is not yet available in TypeScript, some requests and proposals have been made: Support conditional compilation Proposal: Conditional Compilation Proposal: Preprocessor Directives If you are using Visual Studio and MSBuild there’s however a very simple workaround to completely exclude some TypeScript files from being compiled. The solution is to use MSBuild Conditions and/or MSBuild Conditional Constructs, it all depends on how complex your conditional logic will be. In the simplest case you just have to open your .csproj (or .vbproj) file in a text editor and add the proper Condition attribute to the TypeScriptCompile entry; something like: ......

A first look at IncrediBuild

Visual Studio 2015 Update 1 come with a new free bonus: You can download and install a new version of IncrediBuild. If you install it through Visual Studio you’ll get a version of IncrediBuild specifically designed for the environment that will allow you to keep using 8 cores for parallel builds even when the trial license expires (normally it will be limited to 4 cores). To install it use the “File \ New \ Project…” menu, then look for a link called “Build Accelerators”, inside it you’ll find the template used to install IncrediBuild. Once you ‘open’ the link, the...

Jekyll - Pygments, mistyping the syntax highlight language tag results in blog build fail

Jekyll on GitHub uses liquid tags and Pygments as its default syntax highlighter. It generally works great, but sometimes it can cause troubles to the Jekyll build process, especially if you mistype the language it should output. This is the syntax you should use: {% highlight languageTag %} … your code goes here … {% endhighlight %} The problem is: if you mistype the ‘languageTag’ chances are that Jekyll is not able to build the site anymore and the returning message from GitHub isn’t of much help; in the emails sent to me I could read: “The page build failed...

Fluent Interface and Class Hierarchy in C#

Do you like to have fluent interfaces in your code because they make it more readable? Do you have a ‘deep’ class hierarchy and you’d like to have a fluent interface without the need of always returning the base class type? and possibly avoid all the cast(s) in the methods’ chain? Here’s the standard way of approaching Fluent Interfaces with inherited classes in C#: public class Calculator { public Calculator Add() { // do the job return this; } } public class ScientificCalculator : Calculator { public ScientificCalculator Sin() { // do the job return this; } } public class...

AngularJs 1.x and TypeScript best practices - bindToController

One of my best practices when creating new Angular components using TypeScript is to use classes when defining Service(s) and Controller(s) and to use the ‘controllerAs’ syntax for the bindings. You can take a look at the material from my session at the Italian AngularConf2015 in the previous posts to have a better idea of what I mean. Some code samples are also available to better illustrate the matter. There’s however a problem when it comes to the ‘controllerAs’ syntax and directives that define an isolated scope and use properties on that scope to bind values from the outside world....

AngularConf2015 - Slides and Code Samples

Last week I had the honor and the priviledge to give speech at the italian AngularConf 2015, which was held at the Environment Park in Turin (Italy). It was a very good event with many interesting sessions on Angular 1.x and a look some aspects of Angular 2.0. I’ve hosted a session on which benefits you have when using TypeScript to develop Angular 1.x applications and how your code will change when you move to Angular 2.0. Here are the slides I used as a reference: AngularConf2015 from Alessandro Giorgetti The public repositories with the code samples are hosted on...