A DynamoDB library to ease the use of modeling complex hierarchical relationships and implementing a Single Table Design while keeping your query code readable.
MIT License
956
stars
58
forks
source link
Fix custom attribute type extraction for union types with RecordItem #346
Same issue as #334 but for the EntityItem type. Copied description below:
const key = 'key';
type CustomAttributeTypeName<T> = { [key]: T };
// this is a simplified version of what EntityItem will return for
// the union type
type T1 =
| CustomAttributeTypeName<{ prop1: string; prop2: string; }>
| CustomAttributeTypeName<{ prop1: string }>
| CustomAttributeTypeName<{ prop3: string }>;
// This doesn't work. `{ deploymentId: string; projectId: string; }` is missing from union.
// subtypes for a union items seem to get collapsed.
type T2 = T1 extends CustomAttributeTypeName<infer T> ? T : never;
// This works. underlying union types perserved.
type T3 = T1 extends infer U ? U extends CustomAttributeTypeName<infer U> ? U : never : never;
without the outer unboxing of the union type (the outer infer), TS collapses some of the underlying union types.
Issue
Same issue as #334 but for the
EntityItem
type. Copied description below:without the outer unboxing of the union type (the outer
infer
), TS collapses some of the underlying union types.TS playground example
Before
T2
returnsAfter
T3
returns