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

前端 未结 13 745
无人共我
无人共我 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:39

    In project properties -> "TypeScript Build", you can also simply just uncheck "Do not emit outputs if any errors are reported." Having it checked seems to deactivate transpiling on save, where there is an error or not.

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

    I stumbled upon this problem today: I fixed that by using the new "watch":true compiler option, also available through JSON in most recent TypeScript versions:

    {
      "compilerOptions": {
        "watch": true
      }
    }
    

    After doing that, I had to solve another issue related to the following error that appeared in the output window:

    Object doesn't support property or method 'watchFile'
    

    It turned out that my system was using an outdated version of TypeScript (1.0.x), despite I was sure I had a newer one that came with the Visual Studio 2015 Update 1 (1.7). If you run into this problem, you can easily check your tsc version by typing tsc -v from a command-prompt.

    If it says 1.0.x or anything < 1.7, it's probably due to the fact that you have some old references in your PATH environment variable. Be sure you have 1.7 or later installed by checking inside your Microsoft SDKs folder, which is the one used by Visual Studio to install the TypeScript packages as they get updated:

    C:\Program Files (x86)\Microsoft SDKs\TypeScript
    

    If not, update accordingly. Open CPanel > System > Advanced > Environment Variables, select System Variables and click on Edit; browse through the list looking for any reference to the TypeScript folder, change one of them to make it point to your TypeScript most recent installed version (1.7 or above) and delete any other dupes. See also screenshot below:

    For additional details, read this post on my blog.

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

    This issue seems to have been resolved with the most recent update to the TypeScript Language Services extension.

    See this answer for instructions on how to apply this update.

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

    With typescript 2 you have to delete "outDir": from your tsconfig. Fix the bug for me in visual studio.

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

    Check if you have the TypeScript version installed which is configured in the project. Somehow I received no warning that I don't have TypeScript 3.7 installed, but the compile-on-save feature stopped working silently.

    Once I installed TypeScript 3.7, it was working again.

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

    locate the file i.e. C:\file.ts in your terminal/cmd and type

    tsc file.ts -w // watches for file changes and converts on save
    
    0 讨论(0)
提交回复
热议问题