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
Split up the type checker file into multiple files #40937
Comments
The main reason we haven't done this is performance, as shown in #17861. I felt this way when I first joined the team, but my view has softened as I’ve learned to approach the checker differently. I still think certain parts, like the node builder, would be better suited in their own module, but I would probably not split up the checking of different kinds of syntactic constructs, as suggested. Performance in VS Code isn’t a huge problem for me, but I run a pretty powerful computer, and I would love if we could view the file on GitHub. But of course, we cannot reduce the amount of code or its conceptual complexity by splitting it into different files, so I don’t believe such a change would make it significantly easier to understand. In my opinion, the only way to begin to understand the checker is by debugging. While fairly high-level and not specific to the checker, I wrote a blog post on some debugging tips specific to this codebase. I would also suggest @orta’s typescript-notes and @sandersn’s manual as good learning resources that you won’t find in official documentation. Aside from that, you can look at the good first issue and help wanted labels and learn by contributing to the compiler. Depending on your level of familiarity with TypeScript and compilers in general, you may find some that can ease you into understanding the checker bit by bit. For housekeeping purposes, I’m going to call this a duplicate of #17861. |
I see, my main issue is just finding things in the type checker, like if i wanted to find the entry point or where statements are checked its pretty hard. I would love a dev guide which explains some of the concepts around it and how it works. I have some typechecking experience but tsc seems to have some very specific things. |
The syntactic entrypoints typically have predictable names in the format of |
Yeah it works for expressions but |
Haha i was checking for checkStmt alone |
Ill go ahead and close this as it seems this wont happen soon because of perf reasons 👍 |
Search Terms
Split, TypeChecker, Checker
Suggestion
I would love to see the type checker file be split up into multiple files, as it is it is unreadable, and understanding what is going on is nearly impossible.
Use Cases
The typescript type checker is a very interesting tool, however, it is nearly unreadable, because:
I would love to learn more about it, and eventually make a custom implementation for a tool i am making, but the fact that the checker is a single file makes it nearly impossible to understand.
Examples
Type checking consists of distinct goals and steps, and it is possible to split up those steps, for example, splitting up checking functions, loops, binary expressions, unary expressions, generics, scope analysis, etc.
Checklist
My suggestion meets these guidelines:
This is purely a formatting feature, it has zero impact on the end user.
Relevant issues
#17861 seems to be somewhat relevant and it mentions this:
but it is not further discussed
The text was updated successfully, but these errors were encountered: