rescript-lang / rescript-lang/rescript-react
Implicit type conversion?
未关闭
还没有人认领这个 Issue。
- 主要语言
- ReScript
- 星标
- 517
- 派生
- 45
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从所提供组件中的 ReactEvent.Form.target(evt)["value"] 表达式和 useState setter 开始,然后使用链接的 Playground 重现该行为。将结果与链接的论坛主题进行比较,并确定推断出的类型是否是有意为之;当行为得到澄清或确定了具体的仓库更改时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100