Map on union origin in mapType to better preserve aliases and origins

This commit is contained in:
Anders Hejlsberg committed 2021-01-03 06:41:13 -10:00
1 parent 785d2b7914
commit d98caabaca
1 file changed
+4 -2
+4 -2
View File
@@ -21552,10 +21552,12 @@ namespace ts {
if (!(type.flags & TypeFlags.Union)) {
return mapper(type);
}
const origin = (<UnionType>type).origin;
const types = origin && origin.flags & TypeFlags.Union ? (<UnionType>origin).types : (<UnionType>type).types;
let mappedTypes: Type[] | undefined;
let changed = false;
for (const t of (<UnionType>type).types) {
const mapped = mapper(t);
for (const t of types) {
const mapped = t.flags & TypeFlags.Union ? mapType(t, mapper, noReductions) : mapper(t);
changed ||= t !== mapped;
if (mapped) {
if (!mappedTypes) {