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 conversion? #105

Open
ivan-demchenko opened this issue Nov 30, 2023 · 0 comments
Open

Implicit type conversion? #105

ivan-demchenko opened this issue Nov 30, 2023 · 0 comments

Comments

@ivan-demchenko
Copy link

ivan-demchenko commented Nov 30, 2023

Hello,
I’m exploring rescript-react and noticed a peculiar behaviour. Here’s my test code:

module MyComponent = {
  @react.component
  let make = () => {
    let (value, setValue) = React.useState(_ => 0)
    <>
      <div> {React.string(string_of_int(value))} </div>
      <input
        onChange={evt => {
          let x = ReactEvent.Form.target(evt)["value"] // 1
          setValue(_ => x) // 2
        }}
      />
    </>
  }
}

What I noticed is that on the line marked with // 1 the type of x is 'a, but on line // 2 hovering over x shows the type int. Why is that? I would expect the compiler to ask me to decode the value of x.

Thank you in advance!

P.S.

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

No branches or pull requests

1 participant