【问题标题】:No output with TypeScript 2.0TypeScript 2.0 没有输出
【发布时间】:2017-03-02 18:51:23
【问题描述】:

所以以前(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 的先前版本相比有什么变化吗?如果是这样,我该如何解决?谢谢

【问题讨论】:

  • 您是否尝试过在不同的项目中使用相同的配置?也许是一个基本的 hello world 应用程序?

标签: typescript typescript1.8 typescript2.0


【解决方案1】:

您应该删除排除选项,因为它会排除整个文件夹。也可以使用 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 中的更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-08
    • 2019-08-13
    • 1970-01-01
    • 2017-03-04
    • 2021-04-10
    • 2015-05-11
    • 2018-03-19
    • 2021-02-08
    相关资源
    最近更新 更多