diff --git a/src/misc/is-objectid.ts b/src/misc/is-objectid.ts index c3148a7785..a77c4ee2d5 100644 --- a/src/misc/is-objectid.ts +++ b/src/misc/is-objectid.ts @@ -1,5 +1,5 @@ import { ObjectID } from 'mongodb'; export default function(x: any): x is ObjectID { - return x.hasOwnProperty('toHexString') || x.hasOwnProperty('_bsontype'); + return x && typeof x === 'object' && (x.hasOwnProperty('toHexString') || x.hasOwnProperty('_bsontype')); }