Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Disable freezing without losing helpful, descriptive error messages. #264

Open
acarl005 opened this issue Nov 18, 2016 · 3 comments
Open

Comments

@acarl005
Copy link

My team likes the type checking capabilities of this library. We do not want the object immutability. To disable it, we always set NODE_ENV=production even in development.

This also had the effect of making the error messages much less helpful. For example, when NODE_ENV=development it says this, which we prefer:

TypeError: [tcomb] Invalid value {} supplied to input: Input/tracks: Array<Track>/0: Track/deal: ?Deal/startDate: ?date

But setting NODE_ENV=production changes the same error to this:

TypeError: [tcomb] Invalid value { ... } supplied to input (expected a Input)

This vague error message is making development much harder.

It would be nice if there was a way to configure these two things separately. We would like to disable object freezing but keep the more descriptive error messages. Perhaps two different environment variables like TCOMB_IMMUTABLE=false or ERROR_LOG_LEVEL=2.

@gcanti
Copy link
Owner

gcanti commented Nov 18, 2016

This is weird, with NODE_ENV=production you shouldn't see any error message at all

Object.freeze calls and asserts are executed only in development and stripped out in production (using process.env.NODE_ENV !== 'production' tests)

@acarl005
Copy link
Author

I'm sorry. I forgot to mention that we're using babel-plugin-tcomb. The error message we are seeing must be from their compiled code instead, which produces more vague error messages.

So I guess what we're actually asking for is the ability to disable freezing but keep tcomb's helpful error messages. We don't want to have to set NODE_ENV=production causing babel-plugin-tcomb to switch to the disfavored error messages.

@ArmorDarks
Copy link

Same here. Freezing isn't always wanted thing, unfortunately.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants