Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implicit type coercion #75

Open
2 tasks
Frikki opened this issue Oct 12, 2015 · 4 comments
Open
2 tasks

implicit type coercion #75

Frikki opened this issue Oct 12, 2015 · 4 comments

Comments

@Frikki
Copy link
Member

Frikki commented Oct 12, 2015

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 of value is a string.

  • A Implicit Type Coercion
  • B Throw Exception
@TylorS
Copy link

TylorS commented Oct 12, 2015

B Throw exception.

@staltz
Copy link

staltz commented Oct 12, 2015

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
Copy link

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

@Cmdv
Copy link

Cmdv commented Oct 12, 2015

I'm with A

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

No branches or pull requests

5 participants