Oh no, you're thinking, yet another cookie pop-up. Well, sorry, it's the law. We measure how many people read us, and ensure you see relevant ads, by storing cookies on your device. If you're cool with that, hit “Accept all Cookies”. For more info and to customize your settings, hit “Customize Settings”.

Review and manage your consent

Here's an overview of our use of cookies, similar technologies and how to manage them. You can also change your choices at any time, by hitting the “Your Consent Options” link on the site's footer.

Manage Cookie Preferences
  • These cookies are strictly necessary so that you can navigate the site as normal and use all features. Without these cookies we cannot provide you with the service that you expect.

  • These cookies are used to make advertising messages more relevant to you. They perform functions like preventing the same ad from continuously reappearing, ensuring that ads are properly displayed for advertisers, and in some cases selecting advertisements that are based on your interests.

  • These cookies collect information in aggregate form to help us understand how our websites are being used. They allow us to count visits and traffic sources so that we can measure and improve the performance of our sites. If people say no to these cookies, we do not know how many people have visited and we cannot monitor performance.

See also our Cookie policy and Privacy policy.

This article is more than 1 year old

Microsoft tickles devs with a Release Candidate for TypeScript 3.1

Type declarations? What wizardry is this?

As Ignite gets ever closer, Microsoft has unleashed a Release Candidate of the latest version of its jumped-up JavaScript, TypeScript.

While Windows Insiders get all misty eyed about the words “Release Candidate”, developers can start getting serious about version 3.1, since its release is not far away.

TypeScript is an open source programming language, and was one of the early signs that changes were afoot within Microsoft when it made its first appearance nearly six years ago.

A superset of JavaScript, TypeScript adds optional types to JavaScript that Microsoft claims make it easier to support large scale client or server-side applications.

There is good news (assuming Types do not scare you) and bad news in the Release Candidate of TypeScript 3.1. The good news is the addition of support for mappable tuple and array types, which takes the existing mappable object types functionality in TypeScript and applies it to arrays and tuples.

As Daniel Rosenwasser, TypeScript Program Manager at Microsoft, observed: “Rather than introduce a new concept for mapping over a tuple, mapped object types now just ‘do the right thing’ when iterating over tuples and arrays.” Which indeed it does, although having played with the functionality we’re a little surprised it hasn’t always worked this way as opposed to the nasty (but technically consistent) error thrown in earlier versions of TypeScript.

A second major update, which will ease the pain of migrating to TypeScript, deals with the problem of namespaces. Namespaces don’t play well with the likes of var, let or const declarations, which can make getting code from the likes of untyped React into a TypeScript world headache-inducing. The fix has been to make the type-checker a little cleverer – as Rossenwasser explained: “In TypeScript 3.1, for any function declaration or const declaration that’s initialized with a function, the type-checker will analyze the containing scope to track any added properties.”

Unfortunately, 3.1 also breaks some stuff, so caution does need to be exercised before you fire it up. A large number of vendor-specific types have disappeared from the built-in lib.d.ts library. To be fair, this is no bad thing and an inevitable consequence of working with Web IDL files from the DOM specification. If you absolutely must have those types available, then the advice is to add the declarations locally. Or maybe stop supporting specific browsers, hmm?

More annoyingly, narrowing functions have seen some changes which could cause errors to be thrown and require some tweaking to the syntax.

The final release of 3.1 should occur later this month, which will mean we only have until November to wait before BigInt finally makes an appearance in the language. ®

 

Similar topics

TIP US OFF

Send us news


Other stories you might like