mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Unwrap substitutions both before _and_ after potential simplification (#32116)
* Unwrap substitutions both before _and_ after potential simplification * Repeatedly unwrap/simplify until no more can be performed * Use seperate loops for source and target to reduce redundant calls * Move loop into function * Inline worker
This commit is contained in:
@@ -14826,11 +14826,16 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getNormalizedType(type: Type, writing: boolean): Type {
|
||||
return isFreshLiteralType(type) ? (<FreshableType>type).regularType :
|
||||
getObjectFlags(type) & ObjectFlags.Reference && (<TypeReference>type).node ? createTypeReference((<TypeReference>type).target, getTypeArguments(<TypeReference>type)) :
|
||||
type.flags & TypeFlags.Substitution ? writing ? (<SubstitutionType>type).typeVariable : (<SubstitutionType>type).substitute :
|
||||
type.flags & TypeFlags.Simplifiable ? getSimplifiedType(type, writing) :
|
||||
type;
|
||||
do {
|
||||
const t = isFreshLiteralType(type) ? (<FreshableType>type).regularType :
|
||||
getObjectFlags(type) & ObjectFlags.Reference && (<TypeReference>type).node ? createTypeReference((<TypeReference>type).target, getTypeArguments(<TypeReference>type)) :
|
||||
type.flags & TypeFlags.Substitution ? writing ? (<SubstitutionType>type).typeVariable : (<SubstitutionType>type).substitute :
|
||||
type.flags & TypeFlags.Simplifiable ? getSimplifiedType(type, writing) :
|
||||
type;
|
||||
if (t === type) break;
|
||||
type = t;
|
||||
} while (true);
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user