Skip to content

Commit bd3e733

Browse files
fix: guard the value with object
1 parent e1432e6 commit bd3e733

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/type/src/guard/lib/guard-object-key.func.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ import { ResultCallback } from '../../type/result-callback.type';
1111
* @returns A `boolean` indicating whether or not the `value` is an `object` of a generic `Obj` containing the `key`.
1212
*/
1313
export const guardObjectKey: GuardObjectKey =
14-
<Obj>(value: Obj, key: keyof Obj | (keyof Obj)[], callback?: ResultCallback): value is Obj =>
14+
<Obj extends object>(value: Obj, key: keyof Obj | (keyof Obj)[], callback?: ResultCallback): value is Obj =>
1515
isObjectKey<Obj>(value, key, callback);

packages/type/src/guard/lib/guard-object.func.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import { ResultCallback } from '../../type/result-callback.type';
99
* @param callback An optional `ResultCallback` function to handle result before returns.
1010
* @returns A `boolean` indicating whether or not the `value` is an `object` of a generic `Obj`.
1111
*/
12-
export const guardObject: GuardObject = <Obj>(value: Obj, callback?: ResultCallback): value is Obj =>
12+
export const guardObject: GuardObject = <Obj extends object>(value: Obj, callback?: ResultCallback): value is Obj =>
1313
isObject<Obj>(value, callback);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { ResultCallback } from '../../type/result-callback.type';
2-
export type GuardObjectKey = <Obj>(value: Obj, key: keyof Obj | (keyof Obj)[], callback?: ResultCallback) => value is Obj;
2+
export type GuardObjectKey = <Obj extends object>(value: Obj, key: keyof Obj | (keyof Obj)[], callback?: ResultCallback) => value is Obj;
33

44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { ResultCallback } from '../../type/result-callback.type';
2-
export type GuardObject = <Obj>(value: Obj, callback?: ResultCallback) => value is Obj;
2+
export type GuardObject = <Obj extends object>(value: Obj, callback?: ResultCallback) => value is Obj;

0 commit comments

Comments
 (0)