Skip to content

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

Closed

Description

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.

Activity

  1. dbaeumer commented on Oct 11, 2016

    @dbaeumer
    MemberAuthor
  2. changed the title [-]TSServer: how does compile on save work[/-] [+]TSServer: how does compile on save work in 2.0.6[/+] on Oct 11, 2016
  3. added
    Question
    on Oct 11, 2016
  4. dbaeumer commented on Oct 11, 2016

    @dbaeumer
    MemberAuthor

    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.

  5. mhegazy commented on Oct 11, 2016

    @mhegazy
    Contributor

    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.

  6. mhegazy commented on Oct 11, 2016

    @mhegazy
    Contributor

    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.

  7. dbaeumer commented on Oct 12, 2016

    @dbaeumer
    MemberAuthor

    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.

  8. mhegazy commented on Oct 13, 2016

    @mhegazy
    Contributor

    Sure. But not for this release.

  9. movedoa commented on Dec 12, 2016

    @movedoa

    any news on this?

  10. sherwopj commented on Jan 16, 2017

    @sherwopj

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

  11. angelozerr commented on Jan 26, 2017

    @angelozerr

    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?

  12. movedoa commented on Feb 22, 2017

    @movedoa

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

  13. mhegazy commented on Feb 22, 2017

    @mhegazy
    Contributor

    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.

  14. mhegazy commented on Feb 22, 2017

    @mhegazy
    Contributor

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

    movedoa not sure i understand what you are looking for

  15. movedoa commented on Feb 23, 2017

    @movedoa

    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.

  16. Ciantic commented on Mar 12, 2017

    @Ciantic

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

  17. mhegazy commented on Mar 13, 2017

    @mhegazy
    Contributor

    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.

  18. dbaeumer commented on Apr 3, 2017

    @dbaeumer
    MemberAuthor

    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.

  19. movedoa commented on Apr 3, 2017

    @movedoa

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

  20. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions