Stricter object literal assignment checks

TypeScript 1.6 enforces stricter object literal assignment checks for the purpose of catching excess or misspelled properties. Specifically, when a fresh object literal is assigned to a variable or passed as an argument for a non-empty target type, it is an error for the object literal to specify properties that don’t exist in the target type.

Examples
  1. var x: { foo: number };
  2. x = { foo: 1, baz: 2 }; // Error, excess property `baz`
  3. var y: { foo: number, bar?: number };
  4. y = { foo: 1, baz: 2 }; // Error, excess or misspelled property `baz`

A type can include an index signature to explicitly indicate that excess properties are permitted:

  1. var x: { foo: number, [x: string]: any };
  2. x = { foo: 1, baz: 2 }; // Ok, `baz` matched by index signature