Using TypeScript in an existing Visual Studio Web Site project

前端 未结 8 2213
南旧
南旧 2020-11-29 06:16

I\'ve got an existing Visual Studio project that was setup as a \"Web Site\" project. You can create projects like this by going to File->New Web Site. This is a different

8条回答
  •  时光说笑
    2020-11-29 06:54

    For this to work on my setup, I have the "Automatically compile TypeScript files which are not part of a project" checkbox checked.

    But this wasn't enough. For automatic compilation to work in a website project, I had to create a tsconfig.json file with the following configurations:

    {
    "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5",
        "alwaysStrict": true,
        "module": "amd"
    },
    "compileOnSave": true,
    "exclude": [
        "node_modules",
        "wwwroot",
        "packages"
    ]
    }
    

    The "compileOnSave": true setting is the crucial one here. It's what triggers automatic compilation.

    Typescript version 2.1.5 on Visual Studio 2017

提交回复
热议问题