You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TSServer: how does compile on save work in 2.0.6 #11526
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.
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.
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.
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.
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.
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:
exportletPI=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:
exportletPIXXXXXXXXXXXXXX=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?
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.
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.
Mohamed Hegazy (@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.
Activity
dbaeumer commentedon Oct 11, 2016
Mohamed Hegazy (@mhegazy) Vladimir Matveev (@vladima) can you please clarify this.
[-]TSServer: how does compile on save work[/-][+]TSServer: how does compile on save work in 2.0.6[/+]dbaeumer commentedon Oct 11, 2016
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 commentedon Oct 11, 2016
The
CompileOnSaveAffectedFileListRequestshould return an empty list for projects that do not support compile-on-save.mhegazy commentedon Oct 11, 2016
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 commentedon 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 commentedon Oct 13, 2016
Sure. But not for this release.
movedoa commentedon Dec 12, 2016
any news on this?
sherwopj commentedon Jan 16, 2017
+1 compileOnSave: seeing the effects of my bungling on closed files would be marvellous
angelozerr commentedon 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.tsfile like this:and a
b.tsfile like this:In other words
b.tsdepends ona.ts.Now I changed
a.tslike this:and I save the file.
The uses of
CompileOnSaveAffectedFileListRequesttell me thata.tsandb.tsmust be compiled. That's cool. But I need to markb.tsfile with errors (even if it is not opened). So today I don't know how to manage that. My idea is to try to executegeterrForProjectat the end of the compile on save but I'm not sure that it's the clean mean.I tell me if
CompileOnSaveEmitFileRequestcould return diagnostic?movedoa commentedon Feb 22, 2017
ping for status on this, can we expect this in the near future?
mhegazy commentedon Feb 22, 2017
Why are errors relevant here? Compile on Save should honor
--noEmitOnError.mhegazy commentedon Feb 22, 2017
movedoa not sure i understand what you are looking for
movedoa commentedon Feb 23, 2017
Mohamed Hegazy (@mhegazy) Oh sry if that wasn't clear.
In microsoft/vscode#7015 Dirk Bäumer (@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 commentedon 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 commentedon 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.
dbaeumer commentedon Apr 3, 2017
Mohamed Hegazy (@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 commentedon Apr 3, 2017
Since this is now closed what is the appropriate bug to follow for compileonsave in vsc?