【问题标题】:How to incrementally migrate CRA flow to typescript如何将 CRA 流程增量迁移到打字稿
【发布时间】:2019-09-05 06:04:42
【问题描述】:

有一个带有流程的 create-react-app 项目设置。 我们想将其迁移到 typescript。

按照此处的说明进行操作
https://facebook.github.io/create-react-app/docs/adding-typescript
我添加了打字稿。

现在我得到了类型只能在.ts 文件中使用的编译错误。

如果我将 js 文件更改为 ts typescript 比 flow 更严格,就会开始抱怨很多错误。所以我必须一次重写整个应用程序。

有什么方法可以解决这个问题并逐步迁移到 ts?

【问题讨论】:

  • 您可以使用 transpileOnly: true 选项暂时关闭类型检查。

标签: reactjs typescript create-react-app flowtype


【解决方案1】:

这可以通过使用 tsconfig 的 includeexclude 属性来完成。

{
  "include": [
    "src/components",
  ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-03
    • 2015-07-04
    • 2017-02-18
    • 1970-01-01
    • 2019-12-23
    • 1970-01-01
    • 2021-02-18
    • 1970-01-01
    相关资源
    最近更新 更多