MCPcopy Index your code
hub / github.com/nodejs/node / getEffectiveConstraintOfIntersection

Function getEffectiveConstraintOfIntersection

test/fixtures/snapshot/typescript.js:58891–58930  ·  view source on GitHub ↗
(types, targetIsUnion)

Source from the content-addressed store, hash-verified

58889 return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
58890 }
58891 function getEffectiveConstraintOfIntersection(types, targetIsUnion) {
58892 var constraints;
58893 var hasDisjointDomainType = false;
58894 for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
58895 var t = types_5[_i];
58896 if (t.flags & 465829888 /* TypeFlags.Instantiable */) {
58897 // We keep following constraints as long as we have an instantiable type that is known
58898 // not to be circular or infinite (hence we stop on index access types).
58899 var constraint = getConstraintOfType(t);
58900 while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) {
58901 constraint = getConstraintOfType(constraint);
58902 }
58903 if (constraint) {
58904 constraints = ts.append(constraints, constraint);
58905 if (targetIsUnion) {
58906 constraints = ts.append(constraints, t);
58907 }
58908 }
58909 }
58910 else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) {
58911 hasDisjointDomainType = true;
58912 }
58913 }
58914 // If the target is a union type or if we are intersecting with types belonging to one of the
58915 // disjoint domains, we may end up producing a constraint that hasn't been examined before.
58916 if (constraints && (targetIsUnion || hasDisjointDomainType)) {
58917 if (hasDisjointDomainType) {
58918 // We add any types belong to one of the disjoint domains because they might cause the final
58919 // intersection operation to reduce the union constraints.
58920 for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
58921 var t = types_6[_a];
58922 if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) {
58923 constraints = ts.append(constraints, t);
58924 }
58925 }
58926 }
58927 return getIntersectionType(constraints);
58928 }
58929 return undefined;
58930 }
58931 function getBaseConstraintOfType(type) {
58932 if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) {
58933 var constraint = getResolvedBaseConstraint(type);

Callers 1

structuredTypeRelatedToFunction · 0.85

Calls 3

getConstraintOfTypeFunction · 0.85
getIntersectionTypeFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…