|TypeScript 2.7 Improves Type Inference|
|Written by Kay Ewbank|
|Monday, 05 February 2018|
There's a new version of TypeScript that has improvements including easier ECMAScript module interoperability, support for fixed length tuples, and smarter object literal inference.
The improvements to the new version start with stricter class property checks via a new strictness flag that makes sure that each instance property of a class gets set in the constructor body, or by a property initializer. Writing about the change on the MSDN blog, Daniel Rosenwasser, Program Manager on TypeScript says that:
"In a sense, it brings some of the definite assignment checks from variables to instance properties in classes."
The new version also strengthens the use of definite assignment assertions. These cater for situations where properties might be initialized indirectly, such as by a helper method or dependency injection library. You can use a definite assignment assertion to tell the type system that the property will definitely get assigned. In the past this was limited to class properties, but it can now be used on variable declarations.
Other improvements include cleaner output in --watch mode; better formatting of error messages when using the --pretty flag; support for fixed length tuples; and smarter object literal inference.
Summer SALE Kindle 9.99 Paperback $10 off!!
or email your comment to: email@example.com