mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Map on union origin in mapType to better preserve aliases and origins
This commit is contained in:
1 parent
785d2b7914
commit
d98caabaca
1 file changed
+4
-2
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user