Skip to content

Commit

Permalink
FIX: tsc compile of Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael O'Brien committed Nov 25, 2021
1 parent 6a7ba78 commit b28ab72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions src/Model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,15 @@ export type Optional<T extends OneTypedModel> = {
/*
Merge two types
*/
type Merge<A, B> = {
[P in keyof (A & B)]: P extends keyof A ? A[P] : B[P]
type Merge<A extends any, B extends any> = {
[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<T extends OneTypedModel> = Required<T> & Optional<T>
*/
type Entity<T extends OneTypedModel> = Merge<Required<T>, Optional<T>>

Expand Down

0 comments on commit b28ab72

Please sign in to comment.