【问题标题】:Expo Typescript won't build the project, no outDir is producedExpo Typescript 不会构建项目,不会产生 outDir
【发布时间】:2021-09-01 08:43:48
【问题描述】:

我正在尝试构建我的打字稿项目。它在过去使用相同的设置成功构建,但现在它没有构建,即使它没有显示任何错误。我跑:

npx tsc -p tsconfig.json

我的tsconfig.json 在哪里:

{
  "compilerOptions": {
    "module": "ES6",
    "target": "ES6",
    "declaration": true,
    "outDir": "./lib",
    "strict": true,
    "jsx": "react-native",
    "skipLibCheck": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
  },
  "include": [
    "src/**/*"
  ],
  "extends": "expo/tsconfig.base"
}

根本没有生成lib 文件夹。

我的src 文件夹包含几个打字稿文件,以及导出所需组件的索引。

我真的很困惑,因为我的项目结构和设置根本没有改变,tsc 不再生成 outDir 或之前工作时的任何文件。

【问题讨论】:

    标签: javascript typescript react-native


    【解决方案1】:

    Expo 仅使用typescript 进行类型检查。捆绑文件是使用Metro bundler 完成的。因此expo/tsconfig.basenoEmit 选项设置为true

    如果你想自己编译 js 文件,你必须运行你的命令:

    npx tsc -p tsconfig.json --noEmit false
    

    或在tsconfig.json 中将noEmit 选项设置为false。不要忘记将其移回您的tsconfig。或者下一次构建 expo 将同时运行 metro 捆绑和 tsc 类型检查 tsc 编译。

    作为最后的手段,您可以停止在您的tsconfig.json 中扩展expo/tsconfig.base。但只有当你真的知道自己在做什么时才这样做。

    【讨论】:

      猜你喜欢
      • 2017-11-15
      • 1970-01-01
      • 1970-01-01
      • 2018-08-27
      • 1970-01-01
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多