You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, TypeScript's `forEachChild` function has been rewritten to use a function table lookup instead of a `switch` statement across all syntax nodes.
396
-
`forEachChild` is a workhorse for traversing syntax nodes in the compiler, and is used heavily in the binding stage of our compiler, along with parts of the language service.
397
-
The refactoring of `forEachChild` yielded up to a 20% reduction of time spent in our binding phase and across language service operations.
Once we discovered this performance win for `forEachChild`, we tried it out on `visitEachChild`, a function we use for transforming nodes in the compiler and language service.
400
-
The same refactoring yielded up to a 3% reduction in time spent in generating project output.
The initial exploration in `forEachChild` was [inspired by a blog post](https://artemis.sh/2022/08/07/emulating-calculators-fast-in-js.html) by [Artemis Everfree](https://artemis.sh/).
403
-
While we have some reason to believe the root cause of our speed-up might have more to do with function size/complexity than the issues described in the blog post, we're grateful that we were able to learn from the experience and try out a relatively quick refactoring that made TypeScript faster.
TypeScript has to "remember" that`A` must also be an `Animal` when checking if `Zoo<A>` is valid.
417
-
This is basically done by creating a special type that used to hold the intersection of `A` with `Animal`;
418
-
however, TypeScript previously did this eagerly which isn't always necessary.
419
-
Furthermore, some faulty code in our type-checker prevented these special types from being simplified.
420
-
TypeScript now defers intersecting these types until it's necessary.
421
-
For codebases with heavy use of conditional types, you might witness significant speed-ups with TypeScript, but in our performance testing suite, we saw a more modest 3% reduction in type-checking time.
0 commit comments