From b28ab72a7dc153414703c76a5dff4252ccf12dc3 Mon Sep 17 00:00:00 2001 From: Michael O'Brien Date: Thu, 25 Nov 2021 23:26:13 +1100 Subject: [PATCH] FIX: tsc compile of Merge --- README.md | 2 +- src/Model.d.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69ad4fa..88272a7 100644 --- a/README.md +++ b/README.md @@ -1410,7 +1410,7 @@ The are the parameter values that may be supplied to various `Model` and `Table` | throw | `boolean` | Set to false to not throw exceptions when an API request fails. Defaults to true.| | transaction | `object` | Accumulated transactional API calls. Invoke with `Table.transaction` | | type | `string` | Add a `type` condition to the `create`, `delete` or `update` API call. Set `type` to the DynamoDB required type.| -| updateIndexes | `boolean` | Set to true to update index attributes. The default during updates is to not update index values which are defined during create.| +| updateIndexes | `boolean` | Set to true to update index attributes. The default during updates is to not update index values (either primary or secondard) which are defined during create.| | where | `string` | Define a filter or update conditional expression template. Use `${attribute}` for attribute names, `@{var}` for variable substituions and `{value}` for values. OneTable will extract attributes and values into the relevant ExpressionAttributeNames and ExpressionAttributeValues.| If `stats` is defined, find/query/scan operations will return the following statistics in the stats object: diff --git a/src/Model.d.ts b/src/Model.d.ts index 2852341..022adf3 100644 --- a/src/Model.d.ts +++ b/src/Model.d.ts @@ -118,12 +118,15 @@ export type Optional = { /* Merge two types */ -type Merge = { - [P in keyof (A & B)]: P extends keyof A ? A[P] : B[P] +type Merge = { + [P in keyof (A & B)]: P extends keyof A ? A[P] : (P extends keyof B ? B[P] : never) }; /* Create entity type which includes required and optional types + + The following works, but the intellisense types are terrible. Merge does a better job. + type Entity = Required & Optional */ type Entity = Merge, Optional>