4

我正在 VS 2015 update 3 中编写一个项目,并且刚刚安装了 Typescript 2.0。

在经历了很多错误之后,我一直在进行跟踪和错误任务,以使其再次工作。现在我没有任何错误了,但我没有得到我的输出文件。

我的源文件都在客户端文件夹中,并且该文件夹位于项目的根目录中。

这是我的 tsconfig.json:

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "amd",
    "noImplicitAny": true,
    "noEmitOnError": true,
    "moduleResolution": "node",
    "removeComments": true,
    "sourceMap": true,
    "target": "es5",
    "outDir": "./client",
    "outFile": "./client/app.js",
    "sourceRoot": "./client"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

该项目在版本 1.8.x 上时确实可以编译。

这是我的 .ts 文件之一的示例:

namespace app {
    'use strict';

    angular
        .module('app', [
            'ngRoute',
            'ngAnimate',
            'officeuifabric.core',
            'officeuifabric.components'
        ]);

}

我错过了什么吗?

---编辑---如果我删除这些行:

"outDir": "./client",
"outFile": "./client/app.js",
"sourceRoot": "./client"

它可以毫无问题地构建。参数还支持吗?

--edit 2-- 我也一直在用一个空项目测试一个 VS Code 和命令行 tsc。

我的 tsconfig 正在工作:

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "amd",
    "noImplicitAny": true,
    "noEmitOnError": true,
    "moduleResolution": "node",
    "removeComments": true,
    "sourceMap": true,
    "target": "es5",
    "outFile": "app.js",
    "sourceRoot": "./client"
  },
  "exclude": [
    "node_modules"
  ]
}

但是,当我添加 Outdir 时,要么没有编译任何内容,要么位于错误的位置。

这确实有效:

    "outFile": "./build/app.js",
4

2 回答 2

1

我得到这个是出于不同的原因。我有"extends": "@tsconfig/react-native/tsconfig.json",并且外部 tsconfig 正在设置"noEmit": true。我的文件中的一个显式"noEmit": false修复了它。

于 2021-02-20T12:11:59.263 回答
0

这个配置对我有用:

{
  "compileOnSave": false,
  "compilerOptions": {
    "module": "amd",
    "noImplicitAny": true,
    "noEmitOnError": true,
    "moduleResolution": "node",
    "removeComments": true,
    "sourceMap": true,
    "target": "es5",
    "outFile": "./build/app.js"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}
于 2016-10-24T07:22:50.837 回答