kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

`validateType` fails on "empty object": `{}` vs `Object.create(null)` #55

Closed kungfooman closed 9 months ago

kungfooman commented 9 months ago

I'm running into an issue in transformers.js with validateType, because there are multiple ways to make an "object":

image

const value = Object.create(null);
validateType(value, {type: 'object', optional: true}, "loc", "name", true);

image

So far I can't find a good way to represent Object.create(null) as type... but replacing value instanceof Object with typeof value === 'object' should work anyway.

I also need to add some tests for this.

TS Playground