Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile on Build / Compile on Save problems with TS 1.8 in Visual Studio 2015 #6782

Closed
johnnyreilly opened this issue Feb 1, 2016 · 36 comments

Comments

@johnnyreilly
Copy link

commented Feb 1, 2016

Since I installed TS 1.8 I've started noticing that the compile step is not being executed in Visual Studio either on save or upon build when there are existing *.js files in place.

So if I'm working on viewModel.ts then I need to delete viewModel.js and trigger a Visual Studio build in order that a new viewModel.js is created.

My tsconfig.json looks like this:

{
  "compileOnSave": false,
  "compilerOptions": {
    "inlineSourceMap": true,
    "inlineSources": true,
    "noEmitOnError": true,
    "noImplicitAny": true,
    "preserveConstEnums": true,
    "removeComments": false,
    "sourceMap": false,
    "target": "es5"
  },
  "filesGlob": [
    "**/*.ts"
  ],
  "files": [
    // lots of files here - excluded for brevity
  ],
  "atom": {
    "rewriteTsconfig": true
  }
}

I wondered if it might be related to presence of the compileOnSave flag in tsconfig.json (which I believe is supported as of TS 1.8?). However setting it to true and removing it entirely made no discernible differerence to behaviour. (I tried closing and reopening the project in between changes in case there were caching issues but no change.)

So compileOnSave seems entirely broken (i.e. it never compiles on save) and compile on build only works if the existing js files are deleted.

@mhegazy

This comment has been minimized.

Copy link

commented Feb 2, 2016

the compileOnSave property support is not in a released version yet, @paulvanbrenk checked it in today :). it should be available for the 1.8.2.

Can you check your tools\options\Text Editor\TypeScript\Project\Compile on Save, do you have "Automatically compile TypeScript files that are not part of a project" checked? my guess is no, and that is why it is not working. with #2326, you should be able to turn it on using compileOnSave property in tsconfig.json.

@johnnyreilly

This comment has been minimized.

Copy link
Author

commented Feb 2, 2016

Yup that solved it. Thanks @mhegazy.I'll look out for compileOnSave lighting up in when 1.8.2 ships.

@johnnyreilly

This comment has been minimized.

Copy link
Author

commented Feb 16, 2016

@mhegazy - I'm guessing with the VS 2015 TypeScript 1.8 beta plugin I shouldn't expect compileOnSave to be working? I've noticed whilst using Visual Studio that saving is still generating the js files still (even though the flag is set in tsconfig.json).

I wanted to ask about building as well but I'll break that out into a separte issue.

@paulvanbrenk

This comment has been minimized.

Copy link
Contributor

commented Feb 16, 2016

@johnnyreilly Indeed, the compileOnSave option needs new Visual Studio bits.

@johnnyreilly

This comment has been minimized.

Copy link
Author

commented Feb 16, 2016

Thanks @paulvanbrenk.

@mythz

This comment has been minimized.

Copy link

commented Feb 23, 2016

Is tsconfig.json and compileOnSave expected to work on VS 2013? I've installed the latest v1.8.2 of TypeScript for VS2013 and it's missing the "TypeScript JSON Configuration File" new item template for tsconfig.json, adding it manually doesn't disable the TypeScript property page on project properties and none of the configuration on tsconfig.json seems to be overriding either?

@mhegazy

This comment has been minimized.

Copy link

commented Feb 23, 2016

@mythz, tsconfig.json is not supported for Visual Studio 2013. only Visual Studio 2015.

@codler

This comment has been minimized.

Copy link

commented Feb 29, 2016

Seems compileOnSave are not executing same path as VS project root, because out is generating on different path when i do build respective save

@mhegazy

This comment has been minimized.

Copy link

commented Feb 29, 2016

@codler can you share your project?

@paulvanbrenk

This comment has been minimized.

Copy link
Contributor

commented Feb 29, 2016

@codler which version of TypeScript? We've fixed issues in that area.

@hcapp01

This comment has been minimized.

Copy link

commented Mar 17, 2016

@paulvanbrenk I can repro colder's issue on 1.8.4.0.

@mhegazy

This comment has been minimized.

Copy link

commented Mar 17, 2016

@hcapp01 can you share a repro project.

@hcapp01

This comment has been minimized.

Copy link

commented Mar 17, 2016

@mhegazy
I created a minimum repro below. main.js is output to two different path.
https://github.com/hcapp01/tsrepro

@paulvanbrenk

This comment has been minimized.

Copy link
Contributor

commented Mar 17, 2016

@hcapp01 change out to outFile in your tsconfig.json file

@hcapp01

This comment has been minimized.

Copy link

commented Mar 18, 2016

@paulvanbrenk that works. thanks.

@NoelAbrahams

This comment has been minimized.

Copy link

commented May 8, 2016

@mhegazy, do you know what the status of this is?

I'm having trouble getting compile-on-save working. This is the setup I have:

TS Version: 1.8.9 (says 1.8.31.0 on the Visual Studio Help -> About page)
VS Version: VS 2015 Update 2
tsconfig:

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "noImplicitAny": true,
    "sourceMap": true,
    "noEmitOnError": true
  },
  "compileOnSave": true
}

When I build the whole project via right-click -> Build, all the files are compiled correctly.

When I save a specific .ts file, the status bar says "Generation of 'myproject/foo.ts' complete. Remaining files still compiling." This just hangs, and the .js output never gets generated.

Things were working fine before I introduced .tsconfig.

I tried some of the suggested workarounds including turning off noEmitOnError and setting Automatically compile files that are not part of the project..., but nothing seems to work.

@mhegazy

This comment has been minimized.

Copy link

commented May 8, 2016

When I save a specific .ts file, the status bar says "Generation of 'myproject/foo.ts' complete. Remaining files still compiling." This just hangs, and the .js output never gets generated.

The message is somewthing i would expect. it just says it generated foo.ts and working on generating the rest in the background. but it should not hang.

how do you build from the commandline? tsc --p ? or you use a build driver? what happens when you run tsc --p <path to tsconfig.json> --listFiles do you see files that should not be there?

@NoelAbrahams

This comment has been minimized.

Copy link

commented May 8, 2016

@mhegazy, I'm just using Visual Studio. The message "generated foo.js" is also wrong because the file is unchanged.

Sent from my iPhone

On 9 May 2016, at 00:12, Mohamed Hegazy <notifications@github.commailto:notifications@github.com> wrote:

When I save a specific .ts file, the status bar says "Generation of 'myproject/foo.ts' complete. Remaining files still compiling." This just hangs, and the .js output never gets generated.

The message is somewthing i would expect. it just says it generated foo.ts and working on generating the rest in the background. but it should not hang.

how do you build from the commandline? tsc --p ? or you use a build driver? what happens when you run tsc --p --listFiles do you see files that should not be there?

You are receiving this because you commented.
Reply to this email directly or view it on GitHubhttps://github.com//issues/6782#issuecomment-217751909

@mhegazy

This comment has been minimized.

Copy link

commented May 9, 2016

Given the language semantics, generating one file might not be sufficient to get correct output, e.g. Const. enums changes, namespaces, etc.. In VS when saving a file, the file will be generated, then all other files in the project will be generated in the background one at a time. This should end at sometime though :) so what u are seeing seems like a bug.

@cmichaelgraham

This comment has been minimized.

Copy link

commented May 13, 2016

i was seeing something similar. i _believe_ that unloading the project and reloading it seems to have fixed the compile on save that i added to tsconfig.json. maybe it doesn't take effect until the project is reloaded?

@cmichaelgraham

This comment has been minimized.

Copy link

commented May 13, 2016

& hello again @mhegazy 😄

@mhegazy

This comment has been minimized.

Copy link

commented May 13, 2016

it seems to have fixed the compile on save that i added to tsconfig.json.

This looks like a bug to me. @paulvanbrenk thoughts?

@mhegazy

This comment has been minimized.

Copy link

commented May 13, 2016

@cmichaelgraham do you mind filing another issue for this?

@mhegazy

This comment has been minimized.

Copy link

commented May 13, 2016

and hello @cmichaelgraham, good to see you!

@paulvanbrenk

This comment has been minimized.

Copy link
Contributor

commented May 13, 2016

Not sure, are the other settings in the tsconfig.json picked up?

@Methodician

This comment has been minimized.

Copy link

commented Jun 24, 2016

Here's what I don't get: it sometimes works fine and others it doesn't!

I can't for the life of me figure out what I'm doing right or wrong when, or if I even have any influence on this at all. It's almost more frustrating to have it work "sometimes" than to just never work.

My workaround sucks. Today, it simply doesn't work so I am back to the habit of hitting "Rebuild" every time I make the tiniest change. Please tell me you've found a better temporary workflow/workaround until this is fixed!!!

But yesterday it was all unicorns and rainbows. Everything was flowing beautifully in the same solution, same IDE, same computer. No idea what changed. If it works sometimes, maybe there's a tweak to get it to work always?

@Methodician

This comment has been minimized.

Copy link

commented Jun 24, 2016

Please share your workarounds

I guess this problem has been around for a while now and like me, if you're still pushing through you must have come up with a pattern, habit, workflow, or workaround that is getting you through each day until this is fixed. Mine is to "rebuild" the whole solution every time I make the tiniest change to any .ts file. Surely someone has come up with a better way. Please do tell!

@paulvanbrenk

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

We found an issue with compile on save and tsconfig.json files, that depended on the order we processed files, which is not always the same. This fix is part of VS 2015 Update 3 [0].

[0] I can't tell you when that will be released, but the RC release has other TypeScript issues, so don't install that.

@Methodician

This comment has been minimized.

Copy link

commented Jun 25, 2016

I installed the Update 3 RC and it has helped with a lot of other problems but not this one. Most vitally, it made the .tfignore file work, which I absolutely need when committing lots of small typescript files to source control and wanting to ignore the transpiled .js and .map.js files.

@paulvanbrenk could you maybe provide a little more detail on the "order we processed files" as I'd like to tinker but honestly don't know what you're talking about.

@gleno

This comment has been minimized.

Copy link

commented Jul 5, 2016

I have very similar issues. Everything compiles correctly, but it takes a very long time, and sometimes randomly flakes out. Wasn't like this with the previous version of TSC.

@mhegazy

This comment has been minimized.

Copy link

commented Jul 5, 2016

@gleno this is an old issue. do you mind filing a new issue, sharing more details about what you are seeing, what version of VS you are using what version of TS, and a project to help investigate the issue.

@mikelunn

This comment has been minimized.

Copy link

commented Jul 28, 2016

I'm using VS 2015 Update 3 and are experiencing a very similar issue. The typescript compiler seems to only work when I do a build. However, if I do a build, and no server side code has changed, the typescript code will not compile.

@gleno

This comment has been minimized.

Copy link

commented Jul 28, 2016

I've recovered my problem by installing an older version of node tools. If
you have just updated, this may be your issue.
On Thu, 28 Jul 2016 at 23:42, Mike Lunn notifications@github.com wrote:

I'm using VS 2015 Update 3 and are experiencing a very similar issue. The
typescript compiler seems to only work when I do a build. However, if I do
a build, and no server side code has changed, the typescript code will not
compile.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6782 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AC1DQsox5RL6iYUR4I_LRzfPGrqVoMaBks5qaRRLgaJpZM4HQq5h
.

@paulvanbrenk

This comment has been minimized.

Copy link
Contributor

commented Jul 29, 2016

@mikelunn As Mohamed mentioned this is a very old issue, can you file a new issue with a sample project. And diagnostic build logs. Thanks

@dudih

This comment has been minimized.

Copy link

commented Aug 18, 2016

I had the same problem in my visual studio update 3.
It's seems that widows didn't get my typescript 1.8 version, but hold the 1.0 version. so I changed it manually. Now it's work. on saving a .ts file, all my project being transpiled correctly.

For more info: http://stackoverflow.com/questions/39021808/vs2015-adding-watch-true-to-tsconfig-json-causing-jserrorscriptexception-0x/39022452#39022452

@ybarbaria

This comment has been minimized.

Copy link

commented Oct 20, 2016

In typescript 2, you need to delete "outDir" in your tsconfig. Works for me.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.