tsc命令未编译到outDir

问题描述

我对tsconfig.json的配置还很陌生,但是我只是想将自己的src目录编译为应该编译的javascript,但这只是不使用编译后的代码创建outDir文件夹。 / p>

这是我的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。如the documentation所述,noEmit仅用于类型检查。

有关更多信息,请检查here