【问题标题】:typescript compiler options not recognized in visual studio 2015Visual Studio 2015 中无法识别的打字稿编译器选项
【发布时间】:2023-03-27 08:25:01
【问题描述】:

我使用 Visual Studio 2015 创建了一个 ASP.NET 5 Empty Website 项目。 我使用以下内容设置了一个 tsconfig.json 文件:

{
      "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
      },
      "exclude": [
        "node_modules",
        "wwwroot"
      ]
}

我已使用以下内容设置了我的 package.json

{
  "version": "1.0.0",
  "name": "ASP.NET",
  "private": true,
  "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",
    "systemjs": "0.19.6",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "0.5.10"
  },
  "devDependencies": {
    "gulp": "3.8.11",
    "gulp-concat": "2.5.2",
    "gulp-cssmin": "0.1.7",
    "gulp-uglify": "1.2.0",
    "rimraf": "2.2.8"

  }
}

但是,当我制作这个测试页面并尝试编译时,我被告知以下内容:

Error   TS1219  Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.  
Error   TS2307  Cannot find module 'angular2/core'. 
Error   TS1148  Cannot compile modules unless the '--module' flag is provided.

即使它是在我的 tsconfig.json 中配置的。有什么想法吗?

【问题讨论】:

  • 打字稿存储库有问题 - github.com/Microsoft/TypeScript/issues/3124
  • 谢谢,这导致了答案。你应该发帖,这样我才能给你信用。我将 tsconfig.json 移动到 wwwroot 站点的根目录并修复了它。以前它位于项目文件的根目录中。我尝试将它放在链接中建议的脚本文件夹中,但这不起作用。把它放在 wwwroot 工作。
  • 那不行,把它放在脚本文件夹中。必须把它放在 wwwroot 中才能生效。

标签: asp.net npm typescript visual-studio-2015 asp.net-core


【解决方案1】:

Anuraj 引导我找到了答案,并且在我查看它时的文档说将它放在 /scripts 文件夹中,但这也不起作用。

将 tsconfig.json 放入 wwwroot 文件夹是可行的。至少在我使用的版本中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 2015-12-30
    • 1970-01-01
    • 2018-02-19
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多