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

Function inferTypeForHomomorphicMappedType

test/fixtures/snapshot/typescript.js:68194–68207  ·  view source on GitHub ↗

* Infer a suitable input type for a homomorphic mapped type { [P in keyof T]: X }. We construct * an object type with the same set of properties as the source type, where the type of each * property is computed by inferring from the source property type to X for the type *

(source, target, constraint)

Source from the content-addressed store, hash-verified

68192 * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for).
68193 */
68194 function inferTypeForHomomorphicMappedType(source, target, constraint) {
68195 if (inInferTypeForHomomorphicMappedType) {
68196 return undefined;
68197 }
68198 var key = source.id + "," + target.id + "," + constraint.id;
68199 if (reverseMappedCache.has(key)) {
68200 return reverseMappedCache.get(key);
68201 }
68202 inInferTypeForHomomorphicMappedType = true;
68203 var type = createReverseMappedType(source, target, constraint);
68204 inInferTypeForHomomorphicMappedType = false;
68205 reverseMappedCache.set(key, type);
68206 return type;
68207 }
68208 // We consider a type to be partially inferable if it isn't marked non-inferable or if it is
68209 // an object literal type with at least one property of an inferable type. For example, an object
68210 // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive

Callers 2

inferToMappedTypeFunction · 0.85

Calls 4

createReverseMappedTypeFunction · 0.85
hasMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected