2 min read
Changes to keyof operator
TypeScript 2.9 changes the behavior of keyof to factor in both unique symbols as well as numeric literal types. TypeScript’s keyof operator is a useful way to query the property names of an existing type. Before Typescript 2.9, keyof never recognized symbolic keys.
With this functionality, mapped object types like Partial, Required, or Readonly can also recognize symbolic and numeric property keys, and no longer drop properties named by symbols.
Introduction of new import( ) type syntax
One long-running pain-point in TypeScript has been the inability to reference a type in another module, or the type of the module itself, without including an import at the top of the file. With Typescript 2.9, their is a new import(…) type syntax.
import types use the same syntax as ECMAScript’s proposed import(…) expressions, and provide a convenient way to reference the type of a module, or the types which a module contains.
Trailing commas not allowed on rest parameters
This break was added for conformance with ECMAScript, as trailing commas are not allowed to follow rest parameters in the specification.
Changes to strictNullChecks
Unconstrained type parameters are no longer assignable to object in strictNullChecks. Since generic type parameters can be substituted with any primitive type, this is a precaution TypeScript has added under strictNullChecks. To fix this, you can add a constraint on object.
never can no longer be iterated over
Values of type never can no longer be iterated over. Users can avoid this behavior by using a type assertion to cast to the type any.