TypeScript “Compile on save” feature not working i

2019-01-10 18:29发布

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 status bar at the bottom of the IDE says Output(s) generated successfully, but the generated .js file doesn't change.

Here's what I've tried:

  • adding the following to the root <Project> element in my .csproj:

    <PropertyGroup>
        <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
    </PropertyGroup>
    
  • checking and unchecking the "Automatically compile TypeScript files which are not part of a project" option in Tools -> Options -> TypeScript -> Project:

    enter image description here

  • double checking to make sure "Compile on save" is checked in my project's TypeScript Build properties:

    enter image description here

What am I missing?

As a side note, the TypeScript compilation step does work as expected when triggered by a regular build.

10条回答
贪生不怕死
2楼-- · 2019-01-10 18:52

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.

查看更多
我只想做你的唯一
3楼-- · 2019-01-10 18:53

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
查看更多
趁早两清
4楼-- · 2019-01-10 18:56

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

查看更多
何必那么认真
5楼-- · 2019-01-10 18:58

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.

查看更多
登录 后发表回答