TypeScript debuted as a beta programming language on October 1, 2012, and since then has gone through many versions that steadily improved its capabilities. And the work is not done; future versions of TypeScript are also on the roadmap.
Where to get TypeScript
What’s next in TypeScript 2.7
TypeScript 2.7 is due in January 2018, and will feature improved type inference for object literals. The upgrade also is slated to support both the JSX fragment syntax and properties named with
const- declared symbols. An incremental builder compiler API is also planned.
At some point perhaps beyond TypeScript 2.7, the language is slated to support project references and provision of specific types to
What’s new in TypeScript 2.6, the current version
TypeScript 2.6 introduced a strict mode flag, which is identified as
--strictFunctionTypes. In strict mode, any function type that does not originate from a method has its parameters compared “contravariantly,” said Microsoft’s Daniel Rosenwasser, program manager for TypeScript.
TypeScript traditionally compared parameters in a “bivariant” manner, allowing for benefits such as a simpler model for working with arrays. TypeScript 2.6 offers a compromise of increasing strictness on all function types except methods while letting TypeScript continue modeling use cases such as event handlers and simpler array handling.
Another key set of new features in TypeScript 2.6 covers error suppression comments, which are introduced via
// @ts-ignore comments. Microsoft has avoided error suppression in TypeScript because most cases where users asked for it could be solved through more accurate declaration files, or using a type assertion to
any, Rosenwasser said.
» Get more details of what’s new in TypeScript 2.6.
What’s new in TypeScript 2.5
Released in September 2017, TypeScript 2.5 includes an enhancement for
catch statements for errors as well as compiler improvements. The catch binding parameters capability in TypeScript 2.5 uses a late-stage ECMAScript feature to make catch binding optional in
catch statements. Making catch binding optional “means we can just omit
unusedError altogether,” said Rosenwasser. The reason for that is there are times when developers expect something might fail by throwing an error, but the developer does not care what the error is.
Support for imports when using the Node module-resolution strategy. The compiler checks whether files originate from “identical” packages. If a file was derived from a package with a package.json containing name and version fields identical to a previously encountered package, TypeScript will redirect to the top-most package. This resolves a situation in which two packages might have identical declaration of classes but contain “private” members that make them structurally incompatible. A side effect of this change is reduction in memory and the runtime footprint of the compiler and language service.
preserveSymlinks compiler flag, which is like to the
–preserveSymlinks flag in Node.js that instructs the module loader to preserve symbolic links when resolving and caching modules.
» Get more details of what’s new in TypeScript 2.5.
What’s new in TypeScript 2.4
Released in June 2017, Version 2.4 of TypeScript offers improved load times with the addition of a dynamic import expressions capability.
TypeScript 2.4 adds a check for weak types, which contain only optional properties and have few restrictions on what can be assigned to them. Microsoft wants to strengthen weak guarantees of these types to catch silent bugs. The new check for weak types will cause code to break, so developers will need to declare properties that exist, add an index signature to a weak type, and use a type assertion.
TypeScript 2.4 offers safer callback parameter checking. “TypeScript will be strict about checking parameters contravariantly with respect to the current check,” Rosenwasser said. The impetus for this change was that TypeScript would check whether parameters are bidirectionally assignable; although this check generally has not caused any issues, this model did break down on containers that handed internal data from callbacks.
» Get more details of what’s new in TypeScript 2.4.
What’s new in TypeScript 2.3
Released in April 2017, TypeScript 2.3 supports async generators and iterators. Async generators can await at any point.
TypeScript 2.3 also offers down-level iterator and generator support. Previously, generators were not supported when targeting ECMAScript versions 3 or 5. “The new
--downlevelIteration flag gives users a model where emit can stay simple for most users, and those in need of general iterator and generator support can opt in,” said Rosenwasser. TypeScript 2.3 thus makes it easier to use libraries like Redux-saga, where support for generators is expected.
To address issues with strictness in TypeScript’s type system, TypeScript 2.3 introduces the
--strict flag to implicitly enable common strictness options. The language has options for different levels of strictness. It’s common to begin at the strictest settings so the language can provide the best experience, but the compiler has grown a lot of different options, such as
» Get more details of what’s new in TypeScript 2.3.
What’s new in TypeScript 2.2
TypeScript 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.
» Get more details of what’s new in TypeScript 2.2.
What’s new in TypeScript 2.1
Released in December 2016, TypeScript 2.1 reduces the friction of starting new projects, more powerful type-checking, and tools to write more expressive code.
async functions in TypeScript 2.1 let developers use
await and target ECMAScript 3 and 5 without requiring any other tools. Users can write code around promises while not having to use callbacks.
Version 2.1 adds mapped types, which are produced by taking a union of literal types and computing properties for a new object type. “They're like list comprehensions in Python, but instead of producing new elements in a list, they produce new properties in a type,” said Rosenwasser. Developers using mapped types also no longer have to create new or partial read-only variants of existing types.
Object, rest, and spread functionality in TypeScript 2.1 make it easier to partially copy, merge, and pick apart objects. The upgrade also features a key of operator called Index type query that’s used like a query for keys on object types.
» Get more details of what’s new in TypeScript 2.1.
What’s new in TypeScript 2.0
Key improvements in TypeScript 2.0 include simplified declaration file acquisition, in which declarations for a library are made easier, and non-nullable types, in which
undefined have their own types for developers to express when null/undefined values are acceptable. Because this is a breaking change, Microsoft added the
--strictNullChecks mode to opt into this behavior.
Control flow analyzed types in TypeScript 2.0 can produce the most specific type possible. Also, immutable programming has been made easier in TypeScript 2.0 by declaring properties read-only.
» Get more details of what’s new in TypeScript 2.0.
What’s new in TypeScript 1.8
TypeScript 1.8 also features a module augmentation capability that lets developers design more modular libraries. Previously, TypeScript made the assumption that modules wouldn’t change.
Strings in a type position become string literal types in TypeScript 1.8.
TypeScript 1.8 features control flow analysis to help catch common programming errors.
And statements not guaranteed to execute at runtime are now flagged as unreachable code errors; unused labels are flagged as well.
» Get more details of what’s new in TypeScript 1.8.
What’s new in TypeScript 1.5
Released in July 2015, TypeScript 1.5 simplifies the use of modules and supports the experimental
Decorators function in ECMAScript 7, for attaching metadata to classes and functions. The focus on ECMAScript features moves TypeScript toward the goal of becoming a superset of ECMAScript 6 and offering type-checking for the specification's major features.
» Get more details of what’s new in TypeScript 1.5.
What’s new in TypeScript 1.4
Released in January 2015, TypeScript 1.4 increases support for ECMAScript 6, including a new ECMAScript 6 output mode, support for
const, and support for ECMAScript 6 template strings.
Type system improvements include union types, for specifying that a value is one of a number of different types; type aliases, which better document code and improve readability; and
const enums, a restricted form of enums.
» Get more details of what’s new in TypeScript 1.4.
What’s new in TypeScript 1.0
Released in February 2014, the first production version of TypeScript debuted along with Microsoft’s Visual Studio 2015 IDE. Preproduction versions released to developers included TypeScript 0.9.
» Get more details of what’s new in TypeScript 1.0.