View all newsletters
Receive our newsletter - data, insights and analysis delivered to you
  1. Technology
  2. Software
August 20, 2018

Microsoft TypeScript 3.0: What’s New?

Language provides a richer environment for spotting bugs as you type code.

By CBR Staff Writer

Tech giant Microsoft recently released a new version of its programming language TypeScript (a superset of JavaScript with static typing), with new features such as function parameter listing as tuple types and a new datatype called ‘unknown’.

TypeScript helps enable the construction of large-scale JavaScript applications. The TypeScript compiler emits clean readable JavaScript that runs in any ECMAScript runtime like most browsers and Node.js.

As the Microsoft team said of 3:0’s release: “At its core, this experience means analysing your code to catch things like bugs and typos before your users run into them.”

Few programmers would begrudge that.

These are the most notable features.

Do developers have an ethical responsibility?A New Unknown Datatype

A data type, called “unknown”? Yes, the TypeScript team have created this datatype to improve type safety, which the team claims will help programmers to safely declare types of data that are not known until a later point (runtime).

Traditionally, developers have used the keyword ‘any’ which supports any data type, to handle such scenarios, however this approach does not enforce type safety because ‘any’ can be assigned to anything.

Content from our partners
Unlocking growth through hybrid cloud: 5 key takeaways
How businesses can safeguard themselves on the cyber frontline
How hackers’ tactics are evolving in an increasingly complex landscape

In contrast, ‘unknown’ can only be assigned to a variable once a data type has been subsequently defined using type assertion (essentially telling the data what to look like).

The team states in the release notes: “TypeScript 3.0 introduces a new top type unknown. unknown is the type-safe counterpart of any. Anything is assignable to unknown, but unknown isn’t assignable to anything but itself and any without a type assertion or a control flow based narrowing. Likewise, no operations are permitted on an unknown without first asserting or narrowing to a more specific type.”

Function Parameter Lists as Tuple Types

Parameter lists as tuple types enable developers to interact with function parameters as tuples, meaning that parameters can be assigned types using tuples.

The TypeScript team explains that this will give developers more power when handling data passed into function parameters: “With these features it becomes possible to strongly type a number of higher-order functions that transform functions and their parameter lists”.

This feature was asked for via GitHub in 2015, by a user who does not appear to be on the team themselves; good to see Microsoft listening to the community. With even more features outlined in the release notes, it’s clear that Microsoft’s TypeScript continues to deliver real world value to developers.



Websites in our network
Select and enter your corporate email address Tech Monitor's research, insight and analysis examines the frontiers of digital transformation to help tech leaders navigate the future. Our Changelog newsletter delivers our best work to your inbox every week.
  • CIO
  • CTO
  • CISO
  • CSO
  • CFO
  • CDO
  • CEO
  • Architect Founder
  • MD
  • Director
  • Manager
  • Other
Visit our privacy policy for more information about our services, how New Statesman Media Group may use, process and share your personal data, including information on your rights in respect of your personal data and how you can unsubscribe from future marketing communications. Our services are intended for corporate subscribers and you warrant that the email address submitted is your corporate email address.