TypeScript 2.0 没有输出

No output with TypeScript 2.0

所以之前 (TypeScript 1.8) 我有这个用于我的 tsconfig.json

{
  "compilerOptions": {
      "target": "es6",
      "allowJs": true,
      "jsx": "react",
      "outDir": "../",
      "rootDir": "./",
      "sourceMap": true,
      "inlineSources": true
  },
  "filesGlob": [
      "typings/**/*.d.ts",
      "src/**/*.ts",
      "src/**/*.tsx"
  ],
  "exclude": [
    "."
  ]
}

而且效果很好。但是在更新到 TypeScript 2.0 并尝试编译之后,编译器没有给我反馈,也没有输出。与之前的版本相比,有什么改变破坏了我的 tsconfig 吗?如果是这样,我该如何解决?谢谢

您应该删除排除选项,因为它会排除整个文件夹。还可以使用 include 而不是 filesGlob,请参阅 the tsconfig.json reference。我通常还定义一个命名的输出目录而不是点。在您的情况下,我会将 rootDir 设置为 src。所以试试这个 tsconfig.json 文件:

{
  "compilerOptions": {
      "target": "es6",
      "allowJs": true,
      "jsx": "react",
      "outDir": "dist",
      "rootDir": "src",
      "sourceMap": true,
      "inlineSources": true
  },
  "include": [
      "typings/**/*.d.ts",
      "src/**/*.ts",
      "src/**/*.tsx"
  ]
}

打字系统在 Typescript 2.0 中也得到了显着改进,现在完全包含在 npm 模块中。打字系统发生了很大变化,但现在您可以使用熟悉的语法:

npm install @types/<package> --save

更多信息见on the same page