TypeScript “Compile on save” feature not working in Visual Studio 2015

前端 未结 13 742
无人共我
无人共我 2020-12-02 17:49

The \"Compile on save\" feature isn\'t working for me after upgrading to Visual Studio 2015. When I make a change to a .ts file in my project and save, the sta

相关标签:
13条回答
  • 2020-12-02 18:22

    In my case, I had installed Visual Studio Community 2015 along side VS 2012. I had been using Web Essentials for typescript in 2012 which appeared to conflict with 2015.

    Uninstalling Web Essentials in 2012 fixed the issue for me.

    0 讨论(0)
  • 2020-12-02 18:22

    I had a similar but not the same issue in Visual Studio 2019

    • My project was set up to use TypeScript 2.9
    • I had TypeScript 3.8 installed, and the code did compile, but wouldn't compile on save

    I installed the older version, TypeScript 2.9, restarted VS and then it burst into life

    0 讨论(0)
  • 2020-12-02 18:23

    For me it was this option in tsconfig.json:

    "compileOnSave": true,
    "compilerOptions": { ... },
    

    Restart Visual Studio for this change to take effect.

    0 讨论(0)
  • 2020-12-02 18:27

    Not sure if this will help anyone.

    I though I was having issues compiling, but it was compiling on save. I just didn't have my solution explorer toolbar toggled to show all files.

    The file was there, just waiting impatiently to be added to the project.

    0 讨论(0)
  • 2020-12-02 18:29

    Solution:

    For me, and I am quite sure this is also the case for others, this was due to a mistake in the tsconfig.json.

    You need to add "compileOnSave": true. But in the global section not inside compilerOptions.

    Wrong:
    {
      "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5",
        "compileOnSave": true
    
      },
      "exclude": [
        "node_modules",
        "wwwroot"
      ]
    }
    
    Correct:
    {
      "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5"
    
      },
    "compileOnSave": true,
      "exclude": [
        "node_modules",
        "wwwroot"
      ]
    }
    

    Best regards,

    Anders Both Basechat.

    0 讨论(0)
  • 2020-12-02 18:33

    Exact same problem here. I am using Visual Studio 2015 update 3 and TypeScript 2.9.2.0. In tools/options/projects and solutions/external web tools, I upgraded $(PATH) to the second position. With all these configurations, compileOnSave: true doesn't work for me. The workaround solution is open a command line, run ng build --watch on the side and let node take care of auto compilation

    0 讨论(0)
提交回复
热议问题