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

TSServer: how does compile on save work in 2.0.6 #11526

Closed
dbaeumer opened this issue Oct 11, 2016 · 17 comments
Closed

TSServer: how does compile on save work in 2.0.6 #11526

dbaeumer opened this issue Oct 11, 2016 · 17 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@dbaeumer
Copy link
Member

dbaeumer commented Oct 11, 2016

TypeScript Version: 2.0.6-insider

I looked at the requests and it looks like that clients are responsible to trigger compile from the outside. My understanding is the following assuming that file a.ts changed.

  • we sent a CompileOnSaveAffectedFileListRequest request
  • we receive a response telling us that we have to recompile n files
  • we sent n CompileOnSaveEmitFileRequest to the server.

If this is true then basically the client now implements a builder queue to make this performant. This is especially true if compileOnSave goes with auto save.

And how should I use the force flag. If a file requires n files to be recompiled do I have to call these n files with force= true. The files are usually unchanged.

@dbaeumer
Copy link
Member Author

@mhegazy @vladima can you please clarify this.

@dbaeumer dbaeumer changed the title TSServer: how does compile on save work TSServer: how does compile on save work in 2.0.6 Oct 11, 2016
@vladima vladima added the Question An issue which isn't directly actionable in code label Oct 11, 2016
@dbaeumer
Copy link
Member Author

One addition question: how would we find out if compileOnSave is enabled on a specific project. Currently we don't actively monitor project info or tsconfig.json file. Would we need to do so to find out if a certain file needs to be compiled on save or is this something CompileOnSaveAffectedFileListRequest would take into consideration by reporting no files or by signaling this otherwise.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 11, 2016

Would we need to do so to find out if a certain file needs to be compiled on save or is this something CompileOnSaveAffectedFileListRequest would take into consideration by reporting no files or by signaling this otherwise.

The CompileOnSaveAffectedFileListRequest should return an empty list for projects that do not support compile-on-save.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 11, 2016

If this is true then basically the client now implements a builder queue to make this performant. This is especially true if compileOnSave goes with auto save.

It is not a builder queue, it is just a request queue. The server is single threaded, and can only cancel one request at a time. this allows the client to cancel the request and restart it as needed.

@dbaeumer
Copy link
Member Author

dbaeumer commented Oct 12, 2016

I used the term builder queue since it is somehow strange to compile a TS file to JS without doing a syntax and semantic check as well. Consider the case where you save a file a.ts which causes a compile error in a file b.ts which could result in exceptions when executing b.js. I as a user would expect that if we write b.js we inform the user of potential problems in b.ts as well.

Wouldn't it make more sense the server does this. It is a lot of traffic for something the server can implement a lot better.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 13, 2016

Sure. But not for this release.

@movedoa
Copy link

movedoa commented Dec 12, 2016

any news on this?

@sherwopj
Copy link

+1 compileOnSave: seeing the effects of my bungling on closed files would be marvellous

@angelozerr
Copy link

angelozerr commented Jan 26, 2017

I'm implementing compile on save inside Eclipse, it starts working but I have a question when tss files have some errors.

Imagine you have a a.ts file like this:

export let PI = 3.14;

and a b.ts file like this:

import {PI} from "./a"
console.log(PI)

In other words b.ts depends on a.ts.

Now I changed a.ts like this:

export let PIXXXXXXXXXXXXXX = 3.14;

and I save the file.

The uses of CompileOnSaveAffectedFileListRequest tell me that a.ts and b.ts must be compiled. That's cool. But I need to mark b.ts file with errors (even if it is not opened). So today I don't know how to manage that. My idea is to try to execute geterrForProject at the end of the compile on save but I'm not sure that it's the clean mean.

I tell me if CompileOnSaveEmitFileRequest could return diagnostic?

@movedoa
Copy link

movedoa commented Feb 22, 2017

ping for status on this, can we expect this in the near future?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 22, 2017

But I need to mark b.ts file with errors (even if it is not opened). So today I don't know how to manage that. My idea is to try to execute geterrForProject at the end of the compile on save but I'm not sure that it's the clean mean.

Why are errors relevant here? Compile on Save should honor --noEmitOnError.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 22, 2017

ping for status on this, can we expect this in the near future?

@movedoa not sure i understand what you are looking for

@movedoa
Copy link

movedoa commented Feb 23, 2017

@mhegazy Oh sry if that wasn't clear.
In microsoft/vscode#7015 @dbaeumer said this is the bug to track for compile on save in visual studio code, since there is work to be done in tsserver before this can be implemented.

@Ciantic
Copy link

Ciantic commented Mar 12, 2017

I was following this too, not as a Question but as a bug/feature I expected to be fixed. Is that not the case?

@mhegazy
Copy link
Contributor

mhegazy commented Mar 13, 2017

It is a question, and i believe it has been answered. From an tsserver API perspective, CoS is implemented already. if you have any issues with the API please file a new issue.

@mhegazy mhegazy closed this as completed Mar 13, 2017
@dbaeumer
Copy link
Member Author

dbaeumer commented Apr 3, 2017

@mhegazy when referring to CoS are you referring to a builder or to the CoS API to implement a builder in VS Code itself. As we discussed in various other situations implementing a builder in VS Code simply using the CoS API to travers the dependencies is not very efficient.

@movedoa
Copy link

movedoa commented Apr 3, 2017

Since this is now closed what is the appropriate bug to follow for compileonsave in vsc?

@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.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

7 participants