Closed
Description
TypeScript Version: 2.3.1, VS 2017 Preview 2
Code
// A *self-contained* demonstration of the problem follows...
type S = { items: {whatever:true}};
type ExtractedItems<T> = ({[K in keyof (T | { items: {} })]: { [key: string]: T[K] }} & { items: {} })["items"];
let extractedInline: ({[K in keyof (S | { items: {} })]: { [key: string]: S[K] }} & { items: {} })["items"];
let extractedWithType: ExtractedItems<S>;
Expected behavior:
extractedInline and extractedWithType should have the same type.
Actual behavior:
extractedInline is typed as expected, extractedWithType is typed as {}
.
If this behaviour IS in some way expected, that's not made clear in the documentation. Our natural assumption is that a type alias used in this manner to provide a level of indirection should not change the type.