monet / monet.js

monet.js - Monadic types library for JavaScript
https://monet.github.io/monet.js/
MIT License
1.6k stars 114 forks source link

Exception is thrown if the object is without constructor #257

Open danieltrtwn opened 10 months ago

danieltrtwn commented 10 months ago

Monet.js throws an exception in the following case:

it('should return false for object without constructor', () => {
    const obj = Object.create(null) as object;
    const result = Validation.isInstance(obj); // Exception is thrown
    expect(result).toEqual(false);
});

If you include a check for the constructor property, no exception is thrown and the test is successful:

it('should return false for object without constructor 2', () => {
    const obj = Object.create(null) as object;
    const result = obj.constructor !== undefined && Validation.isInstance(obj);
    expect(result).toEqual(false);
});

image

Version of monet: 0.9.3 Version of TypeScript: 5.2.2