Implicit index signatures

An object literal type is now assignable to a type with an index signature if all known properties in the object literal are assignable to that index signature. This makes it possible to pass a variable that was initialized with an object literal as parameter to a function that expects a map or dictionary:

  1. function httpService(path: string, headers: { [x: string]: string }) { }
  2. const headers = {
  3. "Content-Type": "application/x-www-form-urlencoded"
  4. };
  5. httpService("", { "Content-Type": "application/x-www-form-urlencoded" }); // Ok
  6. httpService("", headers); // Now ok, previously wasn't