microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.94k stars 12.47k forks source link

TypeScript VS: Doesn't re-transpile file when source-control revert-changes #20644

Open ststeiger opened 6 years ago

ststeiger commented 6 years ago

TypeScript integration in Visual Studio 2017:

When I change a typescript-file in a visual studio project ( that is in TFS source control ) then I decide to abandon the change (revert changes from right-click context menu) then Visual Studio correctly replaces the local typescript-file with the server version. But it doesn't re-transpile the changed file.

"compileOnSave": true,

also, the option should then be called/added "compileOnChange", not compileOnSave... Because apparently, these two things are not the same, which i find somewhat surprising... although ...

Consequence is, the JavaScript file doesn't run as it should when debugging.

mhegazy commented 6 years ago

Please provide more information like a repro project, or some steps to consistently reproduce the issue. we will also need a version number for both VS and TS.

I would recommend filing this through Send Feedback tool in VS, which will capture some of the details i asked for.

ststeiger commented 6 years ago

Visual Studio Version: Community 2017 15.3.3 (can't update to 15.5.3 due to the lack of admin rights) TypeScript-Build: Version 2.5 Project Type: ASP.NET WebForms .NET Framework: 2.0 (non-core) TFS 2010

tsconfig


{
  "compileOnSave": true,

  "compilerOptions":
  {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": false,
    "outDir": "../js",
    "rootDir": ".",
    "allowUnreachableCode":  true, 

    "target": "es5",
    //"module": "amd", // define, export, like playground
    //"module": "commonjs", // require
    //"module": "es2015", // just like typescript
    // "module": "system", // System.register
     "module": "umd", // factory, require, exports
    //"module": "esnext", // like typescript
    // "module": "none", // Object.defineProperty, require
    // "module": "commonjs",

    "lib":
    [
      "dom",
      "es5",
      "es2015.promise"
    ]
  },
  "exclude":
  [
    "node_modules",
    "wwwroot"
  ]

  ,"include":
  [
    "./**/*"
  ]

}
mhegazy commented 6 years ago

I am unable to reproduce this issue on latest TS (2.6.2). are you seeing this on all projects, or a specific project? if it is the earlier, can you share that project?

ststeiger commented 6 years ago

I cannot give you the .NET 2.0 web-forms project, as this is proprietary company property. But I can also successfully reproduce this issue in a .NET-Core project with GIT souce-control.

Here's my test project: https://github.com/ststeiger/CoreCms

A) Add typescript file mytest.ts to CoreCMS\TypeScript content: let a = "test123"; save look at the mytest.js file Commit to git B) change content of file mytest.ts to content: let a = "test456"; save look at the mytest.js file git: undo/revert change (mytest.ts) look at the mytest.js file

mytest.js now says: var a = "test456";

while mytest.ts says let a = "test123";

By the way: adding a typescript file to this project takes insanely long - pretty much exactly 60 seconds between clicking add and the file appearing - and the IDE stopping its complete unresponsiveness ... I cannot work like this...

mhegazy commented 6 years ago

I am unable to reproduce the issue with the compile-on-save locally. i see the file generated correctly on latest 15.6 Preview 2.

I am able to see the delay in adding a file thought, investigating.

ststeiger commented 6 years ago

I am able to see the delay in adding a file thought, investigating.

At least, that's good news. Will try at home with latest version.

mhegazy commented 6 years ago

@billti has investigated this yesterday. He traced it down to an msbuild issue with globing (tracked by https://developercommunity.visualstudio.com/content/problem/118255/vs2017-slow-file-operations.html). the good news is the delay is almost gone in 15.6. The msbuild team is still working on fixing the delays completely.

As for the compile-on-save issue, i would say give 15.6 a try and let us know if you are still running into that.

ststeiger commented 6 years ago

I just installed 15.5.6 this evening. After a restart of Visual Studio: The compile-on-save issue is still there - no improvement.

On the speed issue, it got a little less bad. If I add a C# file, time until IDE-response is now down to 5-6 seconds. - Still too slow. It's slower still if I add a typescript file. 6-7 seconds, and up to 12 seconds on some tries. It's a marked improvement from the previous 60 seconds, but it's still too slow.

In addition, I discovered a new problem. If the JS files are checked in in Team-Foundation, or check-in by mistake and then removed from the project, checked in: The JS-file are afterwards write-protected, and TypeScript transpilation silently fails (because TFS has write-protected the JS files). If the project gets published, it will be published with the old JavaScript files. There is no error. It just fails - and tells you it succeeded... You gotta figure out what the problem is. Cost me 15 to 30 minutes yesterday - just figuring out what the problem was. As a result, I missed the train, and stayed for 2 hours overtime instead of just one.

Today, it suddenly crashed after adding/renaming a C# file. Had to edit the project file by hand to remove the duplicate entry. The 2017 IDE seems to be a loose cannon... You know, don't take this personal - I know it's not your fault - but if I'm faster and have less problems editing the source files on Linux with an experimential version of JetBrains Rider instead of with Visual Studio on Windows...

And the computer here at home is a fast one - SSD, 32 GB RAM, 3.4 GHz Quad-Core - Windows 10 - all updates installed. This is ridiculously slow.

mhegazy commented 6 years ago

//cc @billti