【问题标题】:Typescript: tsconfig outFile not working打字稿:tsconfig outFile 不起作用
【发布时间】:2016-02-25 19:54:27
【问题描述】:

我使用 Atom 作为带有 typescript 的 AngularJs 2 项目的开发环境。我在 atom 中添加了 atom-typescript 插件来支持 typescript。 Atom 正在为每个 .ts 文件生成单独的 .js 文件。我想为所有 .ts 文件生成单个 .js 文件。因此,我在 tsconfig.json 中的 comilerOptions 下添加了 outFile 设置。我的 tsconfig.json 如下。

{
  "compilerOptions": {
    "target": "ES5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outFile": "./js/Deployment/single.js"
  },
  "exclude": [
    "node_modules"
  ]
}

看起来不错,但是当我编译项目时,它仍然会在指定位置生成空的 single.js 文件。我不明白我在这里缺少什么。我已经安装了 atom-typescript 8.2.0 版。

我的 package.json 如下。

{
  "name": "Pro1",
  "version": "1.0.0",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.0",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "systemjs": "0.19.6",
    "zone.js": "0.5.10"
  },
  "devDependencies": {
    "concurrently": "^1.0.0",
    "lite-server": "^1.3.1",
    "typescript": "^1.7.3"
  }
}

【问题讨论】:

  • 你确定没有错误阻止它编译吗?
  • 你使用的是什么版本的 tsc?
  • 我使用的是 1.7.3。升级到 1.8 版本后,问题得到解决。谢谢大家及时回复。

标签: angularjs typescript atom-editor tsconfig


【解决方案1】:

看起来不错,但是当我编译项目时,它仍然会在指定位置生成空的 single.js 文件

检查您的typescript 版本。更新到 1.8

`"typescript": "^1.7.3"` 

更多:https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#concatenate-amd-and-system-modules-with---outfile

【讨论】:

  • 你是对的巴萨拉特。这解决了我的问题。我将打字稿更新到 1.8 并且可以正常工作。非常感谢。
猜你喜欢
  • 2020-10-12
  • 2020-03-18
  • 1970-01-01
  • 2017-02-20
  • 2018-02-08
  • 2016-11-21
  • 2021-09-25
  • 2016-06-16
  • 2018-05-25
相关资源
最近更新 更多