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

Function distributeIndexOverObjectType

test/fixtures/snapshot/typescript.js:62286–62294  ·  view source on GitHub ↗
(objectType, indexType, writing)

Source from the content-addressed store, hash-verified

62284 type;
62285 }
62286 function distributeIndexOverObjectType(objectType, indexType, writing) {
62287 // (T | U)[K] -> T[K] | U[K] (reading)
62288 // (T | U)[K] -> T[K] & U[K] (writing)
62289 // (T & U)[K] -> T[K] & U[K]
62290 if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
62291 var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
62292 return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types);
62293 }
62294 }
62295 function distributeObjectOverIndexType(objectType, indexType, writing) {
62296 // T[A | B] -> T[A] | T[B] (reading)
62297 // T[A | B] -> T[A] & T[B] (writing)

Callers 2

inferFromTypesFunction · 0.85

Calls 5

getSimplifiedTypeFunction · 0.85
getIndexedAccessTypeFunction · 0.85
getIntersectionTypeFunction · 0.85
getUnionTypeFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…