【问题标题】:How to add a tsconfig.json file to Visual Studio 2015 project for compiler options?如何将 tsconfig.json 文件添加到 Visual Studio 2015 项目以获取编译器选项?
【发布时间】:2016-12-03 01:41:20
【问题描述】:

在 Visual Studio 2015 中使用 TypeScript 项目,显然 tsconfig.json 文件用于创建编译器选项。如何创建一个来修改 TypeScript Web 应用程序的编译器选项?

例如,当我将以下库添加到 TypeScript 时。

import { bootstrap } from '@angular/platform-browser-dynamic';

在编译器选项中需要 --module 标志。但是,Visual Studio 2015 似乎没有在项目中显示此文件。所以,我想创建一个就足够了。

这是文件层次结构:

【问题讨论】:

    标签: angularjs json typescript configuration-files


    【解决方案1】:

    您需要将以下compilerOptions 添加到tsconfig.json 文件中。

    {
      "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
      }
    }
    

    请参阅此源项目here 以获得更多帮助。这是一个工作 angular 2 项目。希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      您需要添加 tsconfig.json 文件并根据您的需要设置以下选项。

          {
        "compilerOptions": {
          "allowJs": true,
          "module": "system",
          "rootDir": "./app",
          "sourceMap": true,
          "target": "es5"
        }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-15
        • 2017-11-12
        • 1970-01-01
        • 2017-04-18
        • 1970-01-01
        • 2021-01-03
        相关资源
        最近更新 更多