Typescript is taking a long time to run, so I used generateTrace
from https://github.com/microsoft/TypeScript/pull/40063
It showed that most of the time was comparing complicated classes with their subclasses. E.g. one of the classes is the base Objection model (https://github.com/vincit/objection.js), which is the base class that all my models inherit.
E.g. I have code like:
class User extends Model {}
function doSomething(model: typeof Model) {}
doSomething(User);
I have ~50 models. I think the first time TS encounters each model is slow, then it caches it. It takes about 5s for TS to compare a specific model with the base Model
. The Model
uses types from several libraries. Here’s a screenshot of the trace, it takes 5min just to compare each model with Model
:
Is there a way to get TS to stop comparing Model
with itself? I.e. since User
extends Model
, there’s no need to check the fields it inherited.