Microsoft TypeScript 2.0 Language — Ready for Prime Time in IT?
Version 2.0 adds features such as non-nullable types and expanded control flow analysis. Plus tagged unions, the never type, this types for functions, and of course glob support. Got all that?
Anyway, it’s gaining huge momentum among developers. In today’s IT Newspro, we resist the temptation to say developersdevelopersdevelopers.
What’s the story? Peter Bright shines a light on TypeScript:
You hear that Mister Tim Anderson? That is the sound of inevitability: [You’re fired -Ed.]
[It] is hosted on GitHub.com, where it is the 15th most popular language…with 250 per cent growth year on year. … The most notable feature in TypeScript 2.0 is non-nullable types. … The compiler will check…for variables set to null, and for…variables that are used before [being] assigned.
Let’s go to the horse’s mouth, shall we? Microsoft’s Daniel Rosenwasser is excited to announce the announcement—TypeScript 2.0 is now available:
Sounds cool. How do I get it? Arif Bacchus liberates us from self-conscious fear:
To download TypeScript 2.0…you must update TypeScript 2.0 for Visual Studio 2015 with Update 3. To grab it with NuGet, start using TypeScript 2.0 in Visual Studio Code. For, Visual Studio “15” Preview users…TypeScript 2.0 will be included in the next Preview release.
And what’s next? Mary Jo Foley knows all about it:
Moving forward, Microsoft plans to focus on enhancing the…language service and set of tooling.
Fine, but is there a wider context to this? Paul Krill displays an anachronistic image:
But what’s the big deal with disallowing NULL? shutdown -p now explains:
The problem is that the type system is unsound – every reference type is implicitly considered an option type with null. And yet any operation on a reference is permitted even when it wouldn’t be allowed on null – hence, runtime exceptions.
[TypeScript] solves that problem outright. If you have a typed reference, by default, it cannot be null, and any code that’s trying to assign to it something that might be null simply won’t compile. In those places where you actually want to allow null, you can explicitly spell it out in the type, but then you’ll have to do null-checks before you access any member (which effectively changes the type of reference inside the conditional statement to the default never-null type). Again, the compiler enforces all that – so if your entire program was typechecked, there cannot be any runtime null errors.
Effectively, they made null into a true monadic option type, like ‘a option in ML, or Maybe a in Haskell.
Wait, I still don’t quite get it. rasmusbr cuts to the chase:
If you and everyone on your team always writes correct code then it doesn’t matter how you encode non-existent values.…The problem is that writing correct code is sometimes hard and often takes a lot of time.
Main image credit: D. Bagley (cc:by)
More in Visual Studio
AWS Announces Streamlined Deployment for .NET Apps
Jul 12, 2022 | Michael Otey
Microsoft Launches Visual Studio Code Server in Preview
Jul 11, 2022 | Rabia Noureen
Microsoft Releases .NET 7 Preview 1 with Cloud-Native and Container Improvements
Feb 24, 2022 | Rabia Noureen
What is Microsoft Mesh? A New Developer Platform for Mixed Reality Apps
Feb 17, 2021 | Brad Sams
Microsoft to Developers: Project Reunion is the Best Path Forward
May 19, 2020 | Brad Sams
The Dashboard: Microsoft's Unhealthy Relationship With UWP Devs
Sep 23, 2019 | Joseph Finney
Most popular on petri