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

Support sending some commands to syntax TS Server while a project is loading #99643

Closed
mjbvz opened this issue Jun 8, 2020 · 9 comments
Closed
Assignees
Labels
feature-request Request for new features or functionality typescript Typescript support issues verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Jun 8, 2020

Problem

VS Code runs two TS servers for our JavaScript and TypeScript support:

  • Syntax Server. Use for basic syntax related operations, such as outline, auto closing tags, etc. Only loads the current file

  • Semantic server. Used for more advanced operations such as errors and intellisense. Requires loading the entire project

For larger projects, the semantic server can take time to load the entire project and start providing responses. While the project is loading, the user does not get any IntelliSense.

Here's the state of things today:

Stage Syntax Operations (Outline) Semantic Operations (IntelliSense) Diagnostics
Loading Full None None
Loaded Full Full Full

Proposal

We'd like to explore improving the UX while a project is loading by letting the syntax server handle basic semantic operations until the project has been fully loaded:

Stage Syntax Operations (Outline) Semantic Operations (IntelliSense) Diagnostics
Loading Full Partial None
Loaded Full Full Full

While loading is happening, we plan to use the syntax server to implement semantic operations such as hover and IntelliSense.

The key limitation of this approach is that the syntax server only knows about the current file, so it will not be able to provide complete results. For example, IntelliSense would only include suggestions from the current file and would not be able to support auto imports

@mjbvz mjbvz added the typescript Typescript support issues label Jun 8, 2020
@mjbvz mjbvz added this to the June 2020 milestone Jun 8, 2020
@mjbvz mjbvz self-assigned this Jun 8, 2020
mjbvz added a commit that referenced this issue Jun 8, 2020
For #99643

Add a new server option for TypeScript that routes request based on if a project is loading or not

The is enabled by the undocumented `"typescript.tsserver.useSeparateSyntaxServer": "dynamic"` setting
@mjbvz
Copy link
Collaborator Author

mjbvz commented Jun 8, 2020

See microsoft/TypeScript#38564 for the TS work on this

480c98f should enabled this in VS Code (you'll need to wait for the first VS Code 1.47 insiders build). To enable this, just set "typescript.tsserver.useSeparateSyntaxServer": "dynamic". You'll also need to be using a supported TS build

/cc @sheetalkamat @DanielRosenwasser

@mjbvz mjbvz added the feature-request Request for new features or functionality label Jun 8, 2020
@DanielRosenwasser
Copy link
Member

Nice! (@amcasey)

Just to be clear, it looks like it's not just intellisense/completions, right? It looks like the syntax server will basically handle every operation except for diagnostics:

480c98f#diff-f647ee692cab93fdf6b2650168d3f315R530-R533

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jun 9, 2020

Yes, during project load syntax server should now get every command except the diagnostic ones and projectInfo. Let me know if there are any other commands I should add to that list

@amcasey
Copy link
Member

amcasey commented Jun 9, 2020

We probably don't want any of the compile-on-save commands to go to the syntax server.

@amcasey
Copy link
Member

amcasey commented Jun 9, 2020

Organize imports can only mangle things. Personally, I'd also drop semantic classification (e.g. class vs interface) since I don't think a guess is better than nothing (e.g. just knowing its a type).

@DanielRosenwasser
Copy link
Member

I'm not able to see things working better. I've

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jun 9, 2020

@DanielRosenwasser You need to be on the VS code 1.47 insiders builds which have not been released yet. They should come out once we ship the stable version of VS Code 1.46

@DanielRosenwasser
Copy link
Member

D'oh - thanks! By the way, I (like @amcasey) tried out the syntax-only server and the results are pretty great already. Very excited to see how this works out.

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jun 30, 2020

To verify this:

  1. In the VS Code workspace.

  2. Make sure you are using the workspace version of TypeScript (4.0)

  3. Go into a TS file into a core VS Code project

  4. Reload the VS Code window

  5. You should see the Initializing JS/TS language features spinner in the status bar

  6. While this is happening, try some basic operations in a file:

    • Hover
    • Suggest
    • Go to definitions

Keep in mind that these operations only look at the current file while the project is loading. Confirm that once the project loads, you start getting full results

@mjbvz mjbvz closed this as completed Jun 30, 2020
@connor4312 connor4312 added the verified Verification succeeded label Jul 1, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality typescript Typescript support issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants