More simplification + consistent use of getConstraintOfTypeParameter
This commit is contained in:
parent
0fd89399cc
commit
1fd1de9625
|
@ -249,7 +249,7 @@ namespace ts {
|
|||
getTypeOfSymbol,
|
||||
getResolvedSymbol,
|
||||
getIndexTypeOfStructuredType,
|
||||
getConstraintFromTypeParameter,
|
||||
getConstraintOfTypeParameter,
|
||||
getFirstIdentifier,
|
||||
),
|
||||
getAmbientModules,
|
||||
|
@ -6951,21 +6951,12 @@ namespace ts {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
function getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type: Type) {
|
||||
function getBaseConstraintOfType(type: Type): Type | undefined {
|
||||
if (type.flags & (TypeFlags.InstantiableNonPrimitive | TypeFlags.UnionOrIntersection)) {
|
||||
const constraint = getResolvedBaseConstraint(<InstantiableType | UnionOrIntersectionType>type);
|
||||
if (constraint !== noConstraintType && constraint !== circularConstraintType) {
|
||||
return constraint;
|
||||
}
|
||||
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function getBaseConstraintOfType(type: Type): Type | undefined {
|
||||
const constraint = getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type);
|
||||
if (!constraint && type.flags & TypeFlags.Index) {
|
||||
return keyofConstraintType;
|
||||
}
|
||||
return constraint;
|
||||
return type.flags & TypeFlags.Index ? keyofConstraintType : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace ts {
|
|||
getTypeOfSymbol: (sym: Symbol) => Type,
|
||||
getResolvedSymbol: (node: Node) => Symbol,
|
||||
getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type | undefined,
|
||||
getConstraintFromTypeParameter: (typeParameter: TypeParameter) => Type | undefined,
|
||||
getConstraintOfTypeParameter: (typeParameter: TypeParameter) => Type | undefined,
|
||||
getFirstIdentifier: (node: EntityNameOrEntityNameExpression) => Identifier) {
|
||||
|
||||
return getSymbolWalker;
|
||||
|
@ -93,7 +93,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function visitTypeParameter(type: TypeParameter): void {
|
||||
visitType(getConstraintFromTypeParameter(type));
|
||||
visitType(getConstraintOfTypeParameter(type));
|
||||
}
|
||||
|
||||
function visitUnionOrIntersectionType(type: UnionOrIntersectionType): void {
|
||||
|
|
Loading…
Reference in a new issue