CyclicMaterials / molecule-input

A Material Design text field
MIT License
16 stars 3 forks source link

implicit type coercion #75

Open Frikki opened 9 years ago

Frikki commented 9 years ago

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 to value =42` , and so the state ofvalue` is a string.

TylorS commented 9 years ago

B Throw exception.

staltz commented 9 years ago

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.

kaosat-dev commented 9 years ago

Coercion for string <=> int , and other more "common" use cases( A ) , B otherwise

Cmdv commented 9 years ago

I'm with A