runem / lit-analyzer

Monorepository for tools that analyze lit-html templates
MIT License
318 stars 36 forks source link

VS Code TS IntelliSense / code completion performance degraded #90

Closed smile4you closed 4 years ago

smile4you commented 4 years ago

When enabling the plugin in VS Code it takes a very long time (5-10sec.) until it shows any suggestions. This behaviour goes completely away when disabling the plugin. Its a little bit larger project with around 20 lit-element components. It also uses Vaadin Polymer Controls (but I am not talking about any code completion on them) but nothing else.

runem commented 4 years ago

Hi! First of all, thanks for reporting this issue. I'm really sorry that you are experiencing this problem.

Fixing the performance has been my highest priority for quite some time now. To give you some background information, Typescript doesn't allow for manually constructing and type checking, so in order to build lit-analyzer I first had to implement an entire Typescript type checker myself. The reason for the performance issues that you are experiencing is that the type checking didn't evaluate types lazy, but evaluated types in an eager manner, thus resulting in many unnecessary operations. It was quite tricky to fix the problem in https://github.com/runem/ts-simple-type, but I managed to do it with version 1.0.0 recently.

I have been working on a lot of improvements for lit-analyzer in this PR: https://github.com/runem/lit-analyzer/pull/112. Early tests shows performance gains of 15x :tada: I'll close this issue when the PR has been merged into master and the changes has been published.

If you want to, you can try out the beta version of lit-plugin by installing this vsix file: https://github.com/runem/lit-analyzer/suites/880715423/artifacts/10350981

Screenshot 2020-07-06 at 15 08 36

It would be really interesting for me to know how much performance has improved for you if you would like to try it out :-)

(Note that it can still run for up to 3 seconds on the first operation because it needs to find and cache custom elements in your project).