TypeScript 3.0 Adds Project References
Written by Kay Ewbank   
Tuesday, 31 July 2018

The latest release of TypeScript has been released. Version 3.0 has improved project reference support, a new 'unknown' type, and the ability to use tuples in parameter lists.

TypeScript was developed by Microsoft, and is a superset of JavaScript that builds on the ECMAScript standard and includes support for static types. Your TypeScript code then gets transformed into clean, runnable JavaScript. TypeScript includes editor support for Visual Studio 2015 and 2017, Sublime Text 3 and from the next release, Visual Studio Code.

Project reference support is the main change to the new release. It means a project can depend on other projects. Specifically, it means that tsconfig.json files can reference other tsconfig.json files. You can specify dependencies in order to split your code into smaller projects, since it gives TypeScript a way to understand build ordering and output structure. This makes builds faster, and developers can edit and navigate across projects. TypeScript Program Manager Daniel Rosenwasser said it:

"means things like faster builds that work incrementally, and support for transparently navigating, editing, and refactoring across projects."

The next improvement is support for extracting and spreading parameter lists with tuples. TypeScript 3.0 allows rest parameters to be generic, and lets you infer those generics as tuple types. This means that functions with varying parameter lengths can be handled without needing to write out overloads. Instead, you can say that the rest parameter must be a type parameter that extends an array, then re-use that for the arguments passed by call. Tuple types have also been expanded to support this usage.

A new unknown type has also been added. It is similar to the 'any' type already supported by TypeScript, but is intended for APIs that need a way to signal “this can be any value, so you must perform some type of checking before you use it”. Rosenwasser says:

"this forces users to safely introspect returned values, because unknown' is assignable to almost nothing else without a type assertion. You also can’t access any properties off of an unknown, nor can you call/construct them."

The final main improvement is the addition of a new type alias that can be used with the JSX defaultProps used in React. Rosenwasser says that despite the long name of LibraryManagedAttributes, 

"this is just a helper type that tells TypeScript what attributes a JSX tag accepts. The short story is that using this general type, we can model React's specific behavior for things like defaultProps and, to some extent, propTypes."

typescriptlogo

More Information

TypeScript On NuGet

TypeScript On GitHub

Related Articles

TypeScript Adds Unused Span Reporting

TypeScript Adds Conditional Types

TypeScript 2.7 Improves Type Inference

TypeScript 2.5 Adds Optional Catch Binding

TypeScript 2.4 Adds Dynamic Import Expressions  

TypeScript 2.3 Released

TypeScript 2.2 Adds More Code Actions

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Google Adds Premium Tier To Developer Program
29/11/2024

Google has added a premium tier to the Google Developer Program. The new tier is described as providing "a tailored suite of services to help developers throughout the learning, building and deploymen [ ... ]



The Advent of SQL 2024 Has Commenced
11/12/2024

It's Advent - the time of year when we countdown the days to Christmas - and if your are a programmer complete daily coding challenges with the Advent of Code, the Advent of Perl, the Advent of Java,  [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Wednesday, 01 August 2018 )