I've been using unions and intersection types as outlined here on typescriptlang.org but the compile step with
tsc keeps getting longer the more I use this pattern, at least it seems that way.
I've observed at least one open source library making heavy usage of unions that slowed down the build to a crawl when destructuring an Object mapped to one of these type unions. I won't know for sure if they are to blame for slow build times unless I rewrite a bunch of type definitions, so I'm wondering if anyone else has encountered slow builds because of using unions and intersection types with TypeScript?
Are there rules to using this pattern responsibly that I'm missing?
The answer may prompt a rewrite of the type definitions. At the expense of complexity / code duplication, I could gain faster builds. That matters to me, because who wants to sit around waiting for TypeScript to compile? I know I don't.