-
Notifications
You must be signed in to change notification settings - Fork 72
Implement diagnostics #162
Comments
We definitely need this. It should definitely not poll with a setTimeout, but publish them when they become available. I am not familiar enough with the TS API to know what is provided here. |
VS Code also only offers diagnostics for files currently open in the editor and suggests users to run another background task ( There is discussion and work being done to have a running tsserver instance respect the compileOnSave tsconfig.json setting at microsoft/vscode#7015 I believe the simplest implementation would behave like VS Code (only open files). Do you feel the language service should also publish project diagnostics at startup and save? |
@tomv564 that is not true, you can report diagnostics at any time. For example, the PHP language server reports them as soon as they are detected during indexing. |
Agreed, I was exploring why the existing TS support in VS Code doesn't send diagnostics for all files all the time. I'll try to get the same behaviour as the PHP language server if the TS API allows for it. |
Great, diagnostics are flowing once the first file is opened. Two considerations:
Let me know if you would like to close this issue, I can create separate issues for the above. |
Not republishing not-changed diagnostics sounds good. I'm wondering whether there is an efficient way in the compiler API to do this vs deep array comparison. It also looks like diagnostics had a perf impact, a lot more tests are marked as slow now: |
Tracing for diagnostics would be good. |
Whole test time went from 1min to 3min, I'm pretty sure this has a significant perf impact. Definitely need tracing and optimisations in this |
Is there an easy to set up tool for consuming + looking at traces while developing? |
Not that I'm aware of, it would be useful to have a tracer that just prints to the terminal or serves a HTTP server locally. Wouldn't be hard to build. |
@tomv564 do you think you can fix the performance regressions in the next days? Otherwise I will have to revert the commit (which I would like to avoid) |
You should see a PR with tracing support shortly, it would be super helpful if those traces can reveal where time is spent in the tests? I have a few ideas:
Hope we can avoid reverting, but I understand if you do! |
It should be possible with some tinkering locally, otherwise it should be possible to find out with simple logging too. I think the current pattern of retrieving and sending diagnostics for the whole program on every single re-compile is definitely not the best way to go, if it is possible to do per-file that would of course be better. And if the native way of only showing diagnostics for the open file is more performant we should go for that. Why skipLibCheck? |
skipLibCheck would likely save the compiler work checking installed declarations. Did a quick check on
Sending diagnostics is cheap compared to TS calls, so I suggest we leave optimisation there for later.
|
Great investigation. I wonder why we need to "sync" the program at all (I didn't write that code) - to me it feels like the |
Great idea to try to run without
Setting Because of this overhead, I think the intended usage is to request diagnostics per file as much as possible. Relevant getSemanticDiagnostics logic: https://github.com/Microsoft/TypeScript/blob/master/src/compiler/program.ts#L918-L931) |
Sounds good, let's do it per-file then. |
For the users who use the server through their editor, project-wide diagnostics is probably pretty high on the wish list.
I hacked around a bit in diagnostics-hack, but this functionality probably needs careful design.
Do you have any further requirements (eg. should be optional?) and ideas (eg. how to convert didChange events into eventual notifications)?
Is there a minimal scope for an initial implementation?
The text was updated successfully, but these errors were encountered: