Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tsc/internal/checker/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,18 @@ func CompareTypes(t1, t2 *Type) int {
if c := getSortOrderFlags(t1) - getSortOrderFlags(t2); c != 0 {
return c
}
// Fast path for two unaliased string literal types.
if t1.flags == TypeFlagsStringLiteral && t2.flags == TypeFlagsStringLiteral && t1.alias == nil && t2.alias == nil {
s1 := t1.AsLiteralType().value.(string)
s2 := t2.AsLiteralType().value.(string)
if s1 != s2 {
if s1 < s2 {
return -1
}
return 1
}
return int(t1.id) - int(t2.id)
}
// Order named types by name and, in the case of aliased types, by alias type arguments.
if c := compareTypeNames(t1, t2); c != 0 {
return c
Expand Down
Loading