Open Frikki opened 9 years ago
B Throw exception.
virtual-dom used to do B when giving a number foo
in h('p', foo)
, and people complained. It made a lot of sense to apply coercion for that case. That's why I vote for A but sometimes B. It depends.
Coercion for string <=> int , and other more "common" use cases( A ) , B otherwise
I'm with A
When passing properties to a component, would you prefer that the properties are type checked and throw an exception in case of wrong type, or rather allow JavaScript to implicitly type coerce, i.e., causing a side effect?
In practice, type coercion would mean that if you pass a property to a component, e.g.,
value = 42
, but the component wants it as a string,value
is implicitly coerced tovalue =
42` , and so the state of
value` is a string.