|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.
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
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."
Summer SALE Kindle 9.99 Paperback $10 off!!
or email your comment to: email@example.com
|Last Updated ( Wednesday, 01 August 2018 )|