我有一个ASP。NET核心项目,我得到这个错误时,我试图构建它:

error TS18003: Build:No inputs were found in config file 'Z:/Projects/client/ZV/src/ZV/Scripts/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["../wwwroot/app","node_modules/*"]'.
1>         The command exited with code 1.
1>       Done executing task "VsTsc" -- FAILED.

这是我的tsconfig。json文件:

{
  "compileOnSave": true,
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es5", "dom" ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "../wwwroot/app/",
    "removeComments": false,
    "sourceMap": true,
    "target": "es6"
  },
  "exclude": [
    "../wwwroot/app",
    "node_modules/*"
  ]
}

这是bug还是我做错了什么?我最近把Visual Studio 2015升级到3。有人以前遇到过这种情况吗?


当前回答

我的VSCode在我的tsconfig开始时给了我一条弯曲的线。Json文件,有同样的错误,所以

我确保在“包括”路径中指定的文件夹中至少有一个.ts文件(包括路径中的一个文件夹是空的,这是正常的) 我只是关闭VSCode并重新打开它,这就解决了问题。(唉. .)

我的文件夹结构

    tsconfig.json
    package.json
    bar/
         myfile.ts
    lib/
         (no file)

我tsconfig.json

   "compilerOptions": { ... },
   "include": [
    "bar/**/*",
    "lib/**/*"
   ],
   "exclude": [
    ".webpack/**/*",
    ".vscode/**/*"
   ]
   

其他回答

我有一个tsconfig。Json文件,不适用于任何.ts文件。在一个单独的文件夹里。相反,我只使用它作为通过“extends”:“../Configs/tsconfig.json”的其他tsconfig文件的基础。只要我重命名基本配置文件,以其他如base-tsconfig。Json(并更新了extends语句)错误消失了,扩展仍然工作。

我在根目录(visual studio)中添加了以下内容

{
  "compilerOptions": {
    "allowJs": true,
    "noEmit": true,
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "**/*"
  ],
  "exclude": [
    "assets",
    "node_modules",
    "bower_components",
    "jspm_packages"
  ],
  "typeAcquisition": {
    "enable": true
  }
}

这可能是因为typescript服务器无法找到包含数组所描述的任何文件:

// tsconfig.json
{
  //...
  "include": [
    "./src/"
  ],
}

如果你正在使用VSCode,你可以在编辑器中超级容易地重新启动TS服务器,提示它像这样重新评估文件:

导航到任何.ts或.tsx文件 打开命令面板(CMD + SHIFT + P在mac上) 执行TypeScript: Restart TS server命令:

在现代的typescript配置中,只需要设置"allowJs",而不需要在include目录中添加任何空的.ts文件,例如"src"(在include array中指定)

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
   ...
  },
  "include": [
    "src"
  ]
}

我的解决方案中有4个现有项目的现有tsconfig文件。升级到vs2017后,我遇到了这个问题。正如NicoJuicy所描述的那样,通过向文件添加包含和排除部分(假设是默认的)来修复。