mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
More simplification + consistent use of getConstraintOfTypeParameter
This commit is contained in:
committed by
Mohamed Hegazy
parent
a581eae955
commit
483ed8fb50
+4
-13
@@ -250,7 +250,7 @@ namespace ts {
|
||||
getTypeOfSymbol,
|
||||
getResolvedSymbol,
|
||||
getIndexTypeOfStructuredType,
|
||||
getConstraintFromTypeParameter,
|
||||
getConstraintOfTypeParameter,
|
||||
getFirstIdentifier,
|
||||
),
|
||||
getAmbientModules,
|
||||
@@ -6930,21 +6930,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 {
|
||||
|
||||
Reference in New Issue
Block a user