Improved keyof with intersection types

With TypeScript 2.8 keyof applied to an intersection type is transformed to a union of keyof applied to each intersection constituent.In other words, types of the form keyof (A & B) are transformed to be keyof A | keyof B.This change should address inconsistencies with inference from keyof expressions.

Example

  1. type A = { a: string };
  2. type B = { b: string };
  3. type T1 = keyof (A & B); // "a" | "b"
  4. type T2<T> = keyof (T & B); // keyof T | "b"
  5. type T3<U> = keyof (A & U); // "a" | keyof U
  6. type T4<T, U> = keyof (T & U); // keyof T | keyof U
  7. type T5 = T2<A>; // "a" | "b"
  8. type T6 = T3<B>; // "a" | "b"
  9. type T7 = T4<A, B>; // "a" | "b"