balena-io-modules / typed-error

Apache License 2.0
5 stars 2 forks source link

Make .name less of a foot-gun #2

Open pimterry opened 7 years ago

pimterry commented 7 years ago

As we saw in the UI incident yesterday, .name isn't reliable under minification. Can we avoid this? One nice deprecation route would be to replace it with a getter that works the same, but prints a deprecation warning any time you try to read it, which should let us quickly find anywhere else this might come up.

pimterry commented 7 years ago

Interesting idea from @emirotin: we could even have this throw in development environments using NODE_ENV (if it's set and it's not production/staging).

pimterry commented 7 years ago

This is not as easy as it sounds, for a few reasons:

I don't see any nice and easy way around those to let us catch incorrect usages of .name. Instead, we're going to have to make it reliable. Thoughts on doing that nicely @emirotin @Page-? The best I can come up with is:

emirotin commented 7 years ago

Yeah, setting it explicitly is probably the way to go