TypeScript 2.1 has been released

TypeScript 2.1 has been released.

As per announcement Announcing TypeScript 2.1, the biggest improvements are:

  • Finally, async/await is available for ES5/ES3 compilation (so: it doesn't require to compile to ES6 anymore).
    This feature is really important, because, like in the C# world, it allows to develop async code in a linear fashion.

  • Object spead: it allows to shallow copy objects, and also to merge more of them in a single final result;
    dually there are object rest, that are used to pickup extra properties in a destructuring operation.

  • keyof operator: it allows to declare a type as an union string based on the fields of another object or class.
  • Mapped types: they allow to declare a new type as a variation of another type;
    merge with the keyof operator, they allow to declare a new type, based on another type, where all the fields are readonly, or boolean, or nullable, for example.
  • Finally, as now there is a different behaviour in module imports, it is reccomended to change this value in your tsconfig.json file:
        {
            "compilerOptions": {
                "noImplicitAny": true,
                ...
        }

Partial Curl animation in iOS with Modal Segue

When developing a Xamarin.iOS application, I had to navigate from the first view controller to a second view controller. To do this, I have used a Modal Segue.

The problem was the once reached the second view controller, touching the upper part of the view was unwinding the segue.

I could not understand this behaviour, and my colleague Mark Smith has been able to understand it and point me to the right solution.

 

While the problem is already described in Remove tap recogniser for modal UIView/Partial Curl, the solution is not completely correct (because it completely disable any functionality on the second view controller), the correct solution is found at Partial Curl transition for modal seque in iOS 8.

 

Here is the solution code rewritten in Xamarin/C#:

             public override void ViewDidAppear(bool animated)

             {

                    base.ViewDidAppear(animated);

 

                    foreach (var gesture in View.GestureRecognizers)

                    {

                          if (gesture is UITapGestureRecognizer)

                                 View.RemoveGestureRecognizer(gesture);

                    }

             }

Upgrading from Angular 2.0.0 to Angular 2.0.2

Angular 2.0.2 has been released.

It's astonishing that, exactly like for previous betas and release candidates, even in this case we have a huge amount of changes, that I'm quickly going to list here:

  • support of the TypeScript 2.0.3 compiler (even if strictNullChecks are not supported yet);
  • updated list of npm packages to use;
  • the file app.routes.ts is not needed anymore, and routes are defined directly in app.module.ts;
  • because of the previous point, routes are defined in a different way, directly during module import.

TypeScript 2 has been released

TypeScript 2 has been released (to be exact: version 2.0.3).

 

As by TypeScript 2.0 is now available!, the principal innovations are:

  • Definition file acquisition via npm
    This change is in line with the new Microsoft guideline to use npm (or bower) to acquire client side libraries (and still use NuGet for server side packages); it is also coherent of letting users leverage the TypeScript language even on non-Windows computers, in particular on Mac and Linux, where you can use Visual Studio Code
  • Non nullable types
    It's confirmed that this is a breaking change, so you have to set strictNullChecks to true in your tsconfig.json (by default it is false). Clearly it's strongly suggested to do so
  • Control Flow Analyzed Types
    Even more expanded from what already available in TypeScript 1.8
  • Readonly modified
    Similar to what available in C#

An even more detailed list of the language innovations is in What's new in TypeScript. And also give at look at the Breaking Changes.

 

Finally: you can start using it in Visual Studio 2015 downloading the TypeScript for Visual Studio 2015 plugin (it requires the Update 3).

Error in TypeScript compilation when upgrading to VS DEV15 and TypeScript 2

If you upgrade to TypeScript 2 (incidentally, done automatically by installing VS DEV15), you can get the following errors in a web project containing TypeScript files:

 

  • The "VsTsc" task could not be initialized with its input parameters.
  • The "OutputLogFile" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property.
 
You need to open a Notepad as administrator and edit the file C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets, removing the OutputLogFile parameter.

 

Invoking the debugger from a .NET application

Recently I was in a particular debugging situation where the process that was debugged by Visual Studio was launching another process, and I needed to debug the startup of this second process too (no way to attach to the process from the IDE, then).

So something like the "debugger" instruction in JavaScript.


I have found that the solution is to call:

    System.Diagnostics.Debugger.Launch();