-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
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.
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug