tvcutsem/harmony-reflect

Provide option to turn off warning "getOwnPropertyNames trap is deprecated. Use ownKeys instead"

scotthovestadt opened this issue · 6 comments

I use this library internally for my project https://github.com/scotthovestadt/node-schema-object

harmony-reflect has a bad interaction with very popular library lodash - many lodash methods (such as _.keys, _.merge, and others) will trigger this warning.

Can we setup harmony-reflect with a way to turn the warning off, even if the default behavior is to have it on?

deian commented

Not sure if #65 would help, but that patch also modifies for the warning to only be printed once

@tvcutsem Would you accept a PR?

@scotthovestadt Sorry for the long delay in responding. I'm working with @deian to accept #65 which should fix this issue (at least, it will print the deprecation method just once, if that would be acceptable for your use case).

@tvcutsem I've created a bit of a crazy workaround in my project to completely suppress the error message. I would prefer to remove the workaround, but I really need to be able to suppress the message entirely.

Thank you so much for your time.

I've been thinking some more about this and decided to simply omit the deprecation notice. As you note, other popular libraries may still call unpatched Object.getOwnPropertyNames under the hood, triggering this deprecation notice while there's nothing you can do about it. Since there is a clean fallback anyway, there's not much harm in letting these calls still pass through the old getOwnPropertyNames trap.

I hope this fix is acceptable.