2 min read

After the announcement of Typescript 2.9 RC  back in May, Microsoft’s TypeScript team came out with the release candidate of TypeScript 3.0 last week, unveiling features such as project references, extracting and spreading parameter lists with tuples, a new unknown type and API breaking changes among others.

Let’s discuss the highlights of TypeScript 3.0 RC release.

Project Reference functionality

It allows TypeScript projects to depend on other TypeScript projects. Once these dependencies have been specified in the tsconfig.json file, you can easily split your code into smaller projects. It also provides TypeScript (and tools around it) a way to understand build ordering and output structure.

Extracting and spreading parameter lists using tuples

This functionality helps with reducing the overloading amount for functions of varied parameter lengths. Also, there is no need to write different overloads to support functions with different number of parameters.


TypeScript 3.0 allows to better model scenarios like these by allowing rest parameters to be generic, and concluding those generics as tuple types. This, in turn, demands for richer tuple types to model scenarios such as optional parameters at the end of a parameter list, a final parameter which can be a rest parameter along with empty parameter lists.

A new ‘unknown’ type

Apart from these features, the new unknown type feature can accommodate APIs that uses variable of any value but requires type checking.

Support for the JSX defaultProps

There is also support for the JSX defaultProps used in React. These defaultProps allow the developers to define default values for props during creation of a component, such as a source for an Image component.

TypeScript 3.0 RC also supports a new type alias called LibraryManagedAttributes in the JSX namespace. LibraryManagedAttributes is just a helper type that tells TypeScript what attributes a JSX tag accepts. Using this general type helps model React’s specific behavior for things such as defaultProps and propTypes.

Apart from these features, there are API breaking changes

API Breaking Changes

  • The internal method LanguageService#getSourceFile is removed, after being deprecated for two years.
  • The function TypeChecker#getSymbolDisplayBuilder and its associated interfaces are removed.
  • The deprecated functions escapeIdentifier and unescapeIdentifier are removed.

TypeScript 3.0 release is scheduled for sometime later this month.

For more information on the latest TypeScript 3.0 RC release, check out the official Microsoft Blog.

Read Next

How to work with classes in Typescript

How to install and configure TypeScript

 


Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.

LEAVE A REPLY

Please enter your comment!
Please enter your name here