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


SnapCode: A Java IDE for the Web
27/02/2024

Thanks to CheerpJ and WebAssembly you can now run a Java IDE inside your browser and local first.This is SnapCode, and while lightweight and in-browser, is to be not underestimated.



Azure AI And Pgvector Run Generative AI Directly On Postgres
26/03/2024

It's a match made in heaven. The Azure AI extension enables the database to call into various Azure AI services like Azure OpenAI. Combined with pgvector you can go far beyond full text search. Let's  [ ... ]


More News

raspberry pi books

 

Comments




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

Last Updated ( Wednesday, 01 August 2018 )