rescript-lang / rescript-react

Official ReScript bindings for ReactJS

Home Page:https://rescript-lang.org/docs/react/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implicit type conversion?

ivan-demchenko opened this issue · comments

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.