流式检查似乎已关闭

时间:2017-04-17 12:16:25

标签: javascript reactjs types flowtype

在下面的代码中使用Flow,即使我将ID类型更改为字符串,当我总是从对象文字数组中获取一个数字时,我在运行流程时没有出现错误我正在传递给这个无状态反应组件。我错过了什么吗?似乎Flow并没有真正检查我的对象项类型。

type Item = {
  item: {
    id: number,
    title: string,
    category: string,
    description: string,
    link: string,
    release_date: string,
    views: string,
    image: string,
 }
}

// beggining of my react stateless component
const Single = (({ item }: Item ) =>
<li className="col l6 s12">
  <div className="card">
    <div className="card-image">
      <img src={item.image} alt={item.title} />
    </div>
    <div className="card-content">
      <span className="card-title">{item.title}</span>
      <p>{item.description}</p>
      <div className="row">
        <div className="col l6 center">
          <blockquote><h5>Released: {item.release_date}</h5></blockquote>
        </div>
        <div className="col l6 center">
          <blockquote><h5>Views: {item.views}</h5></blockquote>
        </div>
      </div>
    </div>
    <div className="card-action">
      <a href={item.link} target="_blank" rel="noopener noreferrer">Link to course</a>
    </div>
  </div>
  <br />
</li>
);

0 个答案:

没有答案