-
Notifications
You must be signed in to change notification settings - Fork 22
Assertions on object destructuring #141
Comments
This is a bug, thanks for reporting |
Released a fix in https://github.com/gcanti/babel-plugin-tcomb/releases/tag/v0.3.21 @NervosaX out of curiosity, why are you using Flow and babel-plugin-tcomb? |
@gcanti Wow, quick fix, thanks :) I'm actually only just using the two in the last couple of days, hence my current activity. My thoughts so far:
edit: 5) Flow + emacs gives me direct feedback in my editor as I'm coding! |
Sorry, I wasn't clear. I'm a happy Flow user myself (well, actually I don't plan to write vanilla JavaScript anymore), so for me Flow is the baseline: an indispensable tool. In my mind this plugin is just a kind of "gateway drug" to Flow. Then I was wondering what Flow can't catch and how to fill those holes with a runtime type checking library, for example:
Interesting, could you please elaborate a bit more? Are you talking about enforced immutability or something else? |
Oh, I didn't doubt you were a flow user. You'd have to be to create a complicated plugin like this.
Runtime errors, specifically. You can't always account for errors that will happen once your app has loaded and taken an unforeseen path. Specifically anything that is out of your control (third party libraries for example). The same can be said of tcomb not being able to catch all. One thing I've noticed is that it can't handle passing arguments to a function I have no control of (which is understandable, we didn't add an assertion inside the function)... such as a third party dependency with no type definitions. Ie, if I use the flow-typed definition for lodash (https://github.com/flowtype/flow-typed/blob/master/definitions/npm/lodash_v4.x.x/flow_v0.28.x-/lodash_v4.x.x.js) and call: _.sum("hello"); Flow will return an error. At runtime, tcomb has not been able to assert the function internally, so it will fail at runtime. |
This is possibly more of a support question, as there are a lot of holes in my knowledge. I have the following:
So I thought make the items optional:
Both errors kind of make sense from the different perspectives... Is there a way to satisfy both assertions, or am I destined to have to only create a type for each combination of destructured arguments?
The text was updated successfully, but these errors were encountered: