iTranslated by AI
Does tsgo Speed Up ESLint Type Checking?
Introduction
Hi. I'm Keiji, and I usually develop web applications for learning support using Next.js.
Recently, the release of tsgo has been a hot topic because it promises to speed up TypeScript compilation. I use TypeScript daily and feel it's a great language that balances flexibility and robustness, but I do have one slight frustration: type checking with ESLint is slow.
In most cases, it runs at a speed that isn't too bothersome if you're careful not to include unnecessary directories like node_modules in the scope. However, it becomes very noticeable when the number of files increases or when developing in a Dev Container environment.
Just then, I heard the keywords "tsgo" and "compilation speedup," so I looked into whether it might also lead to faster ESLint.
To jump straight to the conclusion: "Since tsgo is not involved in the mechanism of ESLint, it does not contribute to speeding up ESLint."
In this article, I will give a brief explanation of how ESLint works and discuss whether tsgo contributes to speeding up ESLint while considering where tsgo actually takes effect.
What is tsgo? What are the benefits?
tsgo is a TypeScript compiler currently being developed by the TypeScript creators to overcome the weaknesses of the traditional compiler, tsc. It seems there is a plan to eventually replace tsc with it.
tsc had the issue of slow type checking and syntax checking, partly because it operates on a single thread. tsgo addresses this issue by supporting multi-threading through development in the Go language.
In fact, it seems that compilation has been sped up by as much as 10 times.
Source: Porting the TypeScript compiler to Go | What is tsgo, which is 10x faster?
Now, a question might come to mind:
"Oh...? Type checking is being sped up too...?"
However, the type checking mentioned here refers to the check performed when compiling TypeScript, which is different from real-time checking and feedback features like the squiggly lines displayed in the VS Code editor. Please keep this distinction in the back of your mind, as it can be confusing if they get mixed up.
ESLint's Workflow
How ESLint Performs Checks
- Loading the source code
- Generating an AST (Abstract Syntax Tree)
- Detecting errors and warnings by comparing the AST with pre-defined rules
- Providing feedback to the programmer
An AST is a tree-structure representation of source code, as shown in the image. I'll skip the detailed explanation, but it's enough to think of it as: "We generate an AST because it's easier to perform syntax checks on an AST than on the raw source code itself."
Source: Abstract syntax tree (wikipedia)
How TypeScript Type Checking is Performed
Actually, ESLint does not support TypeScript type checking by default. Therefore, if you want to perform TypeScript type checking, you need to install a plugin.
By adding a plugin, the generation logic is modified so that TypeScript type information is reflected in the AST when it's generated during step 2 of the workflow mentioned earlier.
Can tsgo Speed Up ESLint?
What we can understand from the ESLint workflow explained earlier is that "ESLint does not use compilation for TypeScript type checking; instead, it statically generates an AST from the source code."
Therefore, compilers like tsc or tsgo are not utilized.
From this, we can conclude: "Since tsgo is not involved in the mechanism of ESLint, it does not contribute to speeding up ESLint."
By the way
Actually, efforts are being made separately to speed up real-time type checking and feedback features, similar to how ESLint works. So, faster type checking in this regard is only a matter of time.
Although it's still in experimental operation and not a stable version yet, for those who want to improve it immediately, it's a good idea to refer to the following article and install the VS Code extension.
TypeScript 7: TypeScript is going to be 10x faster!
Bonus
I have developed and released a Todo management app using Next.js that helps you manage your tasks while keeping track of your own capacity!
It is the perfect app for those who struggle with things like "quitting after three days" or "creating Todos but failing to complete them because plans fall through." Please give it a try!
Introductory article: "No more failed plans. 'Fillive' — the schedule management app that maximizes your 'potential'"

Discussion