tsc(perf): avoid large unions #30847
                
     Closed
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This is a draft PR that will not get merged, it is posted just as a proof of concept
TLDR: we can cut TSC time almost in half and have a nicer and more responsive development experience
Longer story:
I wanted to understand why the typescript development flow on my machine was slow - code actions on save would take several seconds before type checking was done and errors due to incorrect types would pop-up, this was problematic because it decreased my development speed and resulted in multiple back and fourths between CI and TSC failing to build.
I've written down the investigation process and findings in https://www.notion.so/sentry/Typescript-performance-audit-ac375cf3d9374e66998a6eab2d5539e4
Before ~36s build time:


After ~21s
--diagnostics result before:
--diagnostics result after
The symbols, types, instantiations and memory usage are probably the most notable drops.