Total ordering of types by ahejlsberg · Pull Request #200 · microsoft/typescript-go (original) (raw)
This PR implements a total ordering of types that replaces the previous ordering based on type IDs. The new total ordering depends on type names, declaration order, and/or literal values, but is free of dependencies on type creation order and never requires resolution of constituent types or members. A desirable effect of the new ordering is that in a given program, union type constituents are always ordered (and possibly reduced) the same regardless of when and how the union types are materialized.
I expect there is some performance penalty associated with the new ordering, though it doesn't appear to be significant.
For details on the exact manner in which types are ordered, see the compareTypes function here.