Describe the bug
It seems when I'm doing an import statement in Typescript inside a svelte script block, the extension queues my changes by every single character I write, and then tries to execute them sequentially to provide the language features for vscode (autocomplete, etc).
Doing this takes a few seconds for each "queued" lookup of the language server. So when I'm typing faster, I have to sit there while it tries to apply the language server for the state of the editor from a few seconds ago.
I'm guessing there is a simple queue that just gets executed sequentially, but new changes to that queue don't dequeue everything and just do the last state of the document. Essentially the extension is trying to analyze my code as it was a few seconds ago.
To Reproduce
Write a .ts file somewhere in your project. Put it a few directories deep and then try to import it in a svelte file. Try to make a couple of typos on the way to get there and then mouse over the red squiggly every few seconds. You can see that it's trying to understand the import as it was a few seconds ago.
Expected behavior
Don't make a queue of actions to execute @ the language server. Just take the last state of the editor and check on that.
gif of behavior

System (please complete the following information):
Additional context
Add any other context about the problem here.
These are likely not the imports, but the diagnostics, which are triggered 500 miliseconds idle time (user did not type). I'm also not sure this can be called a bug since it will show the correct diagnostics in the end, just not right away.
The bug is the fact that if I decide to keep typing the delay could take up to 5-10 seconds.
During that time I'm basically getting no help from the language service.
Most of that work is synchronous, we cannot abort stuff. We have to investigate if we indeed get the events queued and then fired immediately after each other so we can debounce.
After investigating a little I don't think there is much we can do there. Most language server events are in the form of a method invocation which expects a response.
Could you specify a little further when those 5-10 seconds of delay occur? How big is your project? What does this delay affect, only diagnostics or everything else, too?
I'll update this with some gifs/explanations soon. Thanks!
If you use svelte-preprocess with version 3.x and don't have typescript: {transpileOnly: true} set, a type check will be done after every preprocessing, which is expensive. Moreover, some of the reported errors are false positives - use svelte-check instead. To speed this up, set transpileOnly to true, or use svelte-preprocess 4.x which no longer does typechecking. If you import interfaces into your components, you will have to rewrite your imports of those.
https://github.com/sveltejs/language-tools/commit/6f3032104098de3ebbe8830a557110e8a1cb5a7c#diff-8097976f4996dc753fe3758815b8bd76 This fixed this problem. Thank you!
Ah, interesting. Makes sense, because now getCodeActions is only called if there are diagnostics that require attention, which means getCodeActions is called way less often, which means less transpilation cycles.