TypeScript 2.2 plays nice with React Native JavaScript

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

TypeScript 2.2 plays nice with React Native JavaScript
Mira DeShazer (CC0)

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.

Copyright © 2017 IDG Communications, Inc.

InfoWorld Technology of the Year Awards 2023. Now open for entries!