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

Function resolveIntersectionTypeMembers

test/fixtures/snapshot/typescript.js:58304–58338  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

58302 return getIntersectionType(mixedTypes);
58303 }
58304 function resolveIntersectionTypeMembers(type) {
58305 // The members and properties collections are empty for intersection types. To get all properties of an
58306 // intersection type use getPropertiesOfType (only the language service uses this).
58307 var callSignatures;
58308 var constructSignatures;
58309 var indexInfos;
58310 var types = type.types;
58311 var mixinFlags = findMixins(types);
58312 var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
58313 var _loop_12 = function (i) {
58314 var t = type.types[i];
58315 // When an intersection type contains mixin constructor types, the construct signatures from
58316 // those types are discarded and their return types are mixed into the return types of all
58317 // other construct signatures in the intersection type. For example, the intersection type
58318 // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature
58319 // 'new(s: string) => A & B'.
58320 if (!mixinFlags[i]) {
58321 var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */);
58322 if (signatures.length && mixinCount > 0) {
58323 signatures = ts.map(signatures, function (s) {
58324 var clone = cloneSignature(s);
58325 clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, mixinFlags, i);
58326 return clone;
58327 });
58328 }
58329 constructSignatures = appendSignatures(constructSignatures, signatures);
58330 }
58331 callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */));
58332 indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos);
58333 };
58334 for (var i = 0; i < types.length; i++) {
58335 _loop_12(i);
58336 }
58337 setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, indexInfos || ts.emptyArray);
58338 }
58339 function appendSignatures(signatures, newSignatures) {
58340 var _loop_13 = function (sig) {
58341 if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) {

Callers 1

Calls 3

findMixinsFunction · 0.85
_loop_12Function · 0.85
setStructuredTypeMembersFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…