Skip to content

Commit fe34022

Browse files
Merge pull request #14 from angular-package/4.0.x
4.0.1
2 parents b465963 + 9c2bbe4 commit fe34022

File tree

9 files changed

+32
-2127
lines changed

9 files changed

+32
-2127
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,20 +1846,23 @@ The **return value** is a `boolean` indicating whether or not the `value` is an
18461846

18471847
`4.0.0`: The function uses [`isObjectKey`](#isobjectkey) function to check the `value` and has [`callback`](#resultcallback) as optional instead of the [`guardObject`](#guardobject).
18481848

1849-
Use `guardObjectKey()` or `guard.is.objectKey()` to guard the `value` to be an `object` of a generic `Obj` type that contains the `key` property of the [`Key`][key] type.
1849+
`4.0.1`: Fix guards the `key` by changing its type to `keyof Obj` instead of just a [`Key`][key].
1850+
1851+
Use `guardObjectKey()` or `guard.is.objectKey()` to guard the `value` to be an `object` of a generic `Obj` type that contains the `key`.
18501852

18511853
```typescript
1852-
const guardObjectKey: GuardObjectKey = <Obj extends object>(value: Obj, key: Key | Key[], callback?: ResultCallback): value is Obj =>
1853-
isObjectKey<Obj>(value, key, callback);
1854+
const guardObjectKey: GuardObjectKey =
1855+
<Obj extends object>(value: Obj, key: keyof Obj | (keyof Obj)[], callback?: ResultCallback): value is Obj =>
1856+
isObjectKey<Obj>(value, key, callback);
18541857
```
18551858

18561859
| Parameter | Type | Description |
18571860
| :---------- | :--------------------------------: | :--------------------------------------------------------------------- |
18581861
| value | `Obj` | A generic `Obj` type `value` that contains the `key` to guard |
1859-
| key | [`Key`][key] \| [`Key[]`][key] | A [`Key`][key] type or an array of [`Key`][key] type name of the property that the `value` contains |
1862+
| key | `keyof Obj` \| `(keyof Obj)[]` | A key of `Obj` or an array key of `Obj` type as the name of the property that the `value` contains |
18601863
| callback? | [`ResultCallback`][resultcallback] | An Optional [`ResultCallback`][resultcallback] function to handle result before returns eg. to throw an `Error` |
18611864

1862-
The **return value** is a `boolean` indicating whether or not the `value` is an `object` of a generic `Obj` containing the [`Key`][key] .
1865+
The **return value** is a `boolean` indicating whether or not the `value` is an `object` of a generic `Obj` containing the `key`.
18631866

18641867
[Example usage on playground][guard-object-key]
18651868

0 commit comments

Comments
 (0)