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

vue-tsc very slow since typescript version 4.9 #2533

Closed
fardolieri opened this issue Mar 21, 2023 · 8 comments · Fixed by #3259
Closed

vue-tsc very slow since typescript version 4.9 #2533

fardolieri opened this issue Mar 21, 2023 · 8 comments · Fixed by #3259

Comments

@fardolieri
Copy link

Good day everyone,

ever since I updated my typescript version from 4.8 to 4.9, my linting times of vue-tsc take significantly longer (about 5 times longer). Updating to typescript 5.0 didn't help either. Before it took a little less than 3 minutes but now they take 15 minutes.

I wanted to know if this is a known problem or if anyone else experiences the same issue?

Sadly I cannot share my company's codebase to give a reproducible example, but if there are other ways to track down the underlying issue I'll gladly offer my help.

@johnsoncodehk
Copy link
Member

This may be a performance regression of TS. Unfortunately, we cannot investigate it without a repro case. It would be helpful if you can try to extract the business code and provide a repro case.

@mlesin
Copy link

mlesin commented Apr 28, 2023

I also noticed significant slowdown, especially when a lot of .vue files with <script setup lang="ts"> are present

@Archetipo95
Copy link

Same here, sorry I can't share a reproduction. But it's very slow vscode

@fardolieri
Copy link
Author

fardolieri commented May 4, 2023

I checked out some larger open source vue projects to see if any of them has this problem but they didn't.

So my first guess is that maybe my hastily assembled monorepo plays a part in this (but I could also be completely wrong on this one). I have multiple Typescript projects (multiple tsconfig.json) that carelessly cross reference themselves like the following. I didn't check if that could have some linting time implications.

// project A
import type { B } from '../../../projectB/foo';

// project B
import type { A } from '../../../projectA/bar';

I'll try to dig further into it when I have some spare time.

@jd-solanki
Copy link
Contributor

jd-solanki commented May 9, 2023

I'm also facing the super slow performance (in vscode) after this commit where I separated tsconfig and extended them: jd-solanki/anu@e4523d2

Does anyone know any clue? It makes it super hard to contribute.


Edit:

I noticed other people are also facing the similar issues where saving time is too long: #2740 (comment)

If you want good production, can above mentioned pattern be the source of inspection?

@mlesin
Copy link

mlesin commented May 11, 2023

I don't know if this is related to this problem, but in my case the option noErrorTruncation: true in tsconfig.app.json slows down the compilation time by a factor of 10 even when no errors occur.

Without this option, the command vue-tsc --noEmit -p tsconfig.app.json --incremental false --composite false runs in 4.8s, with the option enabled, the type check time increases to 46.5s.

@mccxiv
Copy link

mccxiv commented May 18, 2023

but in my case the option noErrorTruncation: true in tsconfig.app.json slows down the compilation time by a factor of 10

This was it for us!! Thank you. Without that option we're back to reasonable type checking speed

@fardolieri
Copy link
Author

fardolieri commented Dec 5, 2023

Okay so I finally found a way to trace down where my slow vue-tsc linting speeds were coming from. I had a really expensive recursive type in one of my projects lying around. This is how I found it:

  • Make sure to have a clean Git tree, because you are about to generate lots of temporary files.
  • Open any vue file.
  • Run VSCode command Volar: Restart VUE server just to make sure to not run into strange caching issues.
  • Run VSCode command Volar (Debug): Write Virtual Files to create a ts file for each SFC file you have.
  • Now instead of running vue-tsc do tsc --noEmit --generateTrace trace, which probably shows lots of errors but the important part is, that there is now a new directory called trace with a trace.json file in it.
  • Open chrome://tracing in Google Chrome and drag&drop the trace.json file in there.
  • This should give you an insight on what files take the longest amount of time to typecheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants