Paul Krill
Editor at Large

TypeScript 2.2 plays nice with React Native JavaScript

news
Feb 7, 20172 mins

Due this month, the upgrade also adds object type and removes restrictions on classes

typewriter typescript
Credit: Mira DeShazer

Microsoft’s TypeScript language is approaching its 2.2 release with an emphasis on support for React Native, Facebook’s JavaScript framework for building native mobile apps.

The upgrade has moved to a release candidate status, which is commonly the last stage before general availability, and a road map for the language has version 2.2 arriving this month.

For React Native, which enables building of native apps via Facebook’s React framework and JavaScript, TypeScript 2.2 offers a JSX emit mode, called react-native, to accommodate React Native’s loader by generating .js files. The loader expects all input to be .js files. “It also satisfies cases where you want to just leave your JSX syntax alone but get .js files out from TypeScript,” Daniel Rosenwasser, Microsoft program manager for TypeScript, said. JSX provides TypeScript with an embeddable XML-like syntax.

Version 2.2 also introduces an object type that lets a developer perform an object primitive type parameter, which should help catch a large class of bugs while more accurately modeling real-world code. To improve support for the mixin pattern, restrictions have been removed on classes. Developers can write a function that takes a constructor, declares a class that extends the constructor, adds members to the new class, and returns the class itself. Mixins enable building up classes from reusable components by combining simpler, partial classes.

Due in May, TypeScript 2.3 is set to feature generator support for ECMAScript 3 and 5, asynchronous iterators, and better support for literal types in JSX attributes. Other features planned for the language include variadic types, which support higher-order functions taking a variable number of parameters; project references; type-checking of computed properties for constraints and symbols; and bundling of module type definitions. Nominal typing support, enabling more-refined types, is being investigated as a possible addition to the language as well.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author