typescript - tsc 命令没有编译到 outDir

标签 typescript typescript-typings tsconfig

我是 tsconfig.json 配置的新手,但我只是想像它应该的那样将我的 src 目录编译为编译的 javascript,但它只是没有创建 outDir 包含编译代码的文件夹。

这是我的tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es2017",
    "skipLibCheck": true,
    "noImplicitAny": true,
    "noEmit": true,
    "moduleResolution": "node",
    "sourceMap": true,

    "outDir": "dist",

    "baseUrl": ".",
    "jsx": "react",
    "paths": {
      "MyApplicationTypes" : ["@types/MyApplicationTypes/index.d.ts"],
      "*": [
        "node_modules/*"
      ]
    },
    "typeRoots" : ["@types"]
  },
  "include": [
    "server/**/*",
    "client/**/*"
  ],
  "exclude" : [
    "./client/dist",
    "./client/.cache",
    "./dist",
    "./.cache"
  ]
}

我的 npm run build 命令只是简单的 tsc,它运行并完成没有任何错误 或任何其他输出。

dist/ 没有创建,即使我手动创建文件夹,它仍然是空的。这是怎么回事?!

我的文件夹结构非常简单,包含服务器和客户端:

- project
  - client
    - index.html
    - index.tsx
    ... etc
  - server
    - index.ts 
    ... etc

有什么理由吗?我的 tsconfig 非常简单

最佳答案

您已将 noEmit 设置为 true。如前所述here , noEmit 仅用于类型检查。

更多信息请查看TS docs.

关于typescript - tsc 命令没有编译到 outDir,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64284042/

相关文章:

angular - tap() 与 subscribe() 设置类属性

使用解构的剩余参数进行 Typescript 函数重载类型推断

angular - 关于 angular4 项目中的 import {**} from @app/*

visual-studio - 是否可以让 VS2017 使用子目录中的 tsconfig.json 文件?

typescript - 为 vue 包创建 typescript 定义文件 (vue-datetime)

typescript - typescript 中的 'static side' 和 'instance side' 到底是什么?

node.js - TypeORM 堆栈跟踪未显示我的代码中的错误来源

typescript - 如何在 typescript 中输入由对象制成的字典?

TypeScript:从装饰器推断返回类型?

在 Web Worker 中导入 tensorflow 时出现 Angular typescript 类型检查问题