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

Function getTypeOfPropertyOfContextualType

test/fixtures/snapshot/typescript.js:72762–72788  ·  view source on GitHub ↗
(type, name, nameType)

Source from the content-addressed store, hash-verified

72760 return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0);
72761 }
72762 function getTypeOfPropertyOfContextualType(type, name, nameType) {
72763 return mapType(type, function (t) {
72764 var _a;
72765 if (isGenericMappedType(t) && !t.declaration.nameType) {
72766 var constraint = getConstraintTypeFromMappedType(t);
72767 var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
72768 var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
72769 if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
72770 return substituteIndexedMappedType(t, propertyNameType);
72771 }
72772 }
72773 else if (t.flags & 3670016 /* TypeFlags.StructuredType */) {
72774 var prop = getPropertyOfType(t, name);
72775 if (prop) {
72776 return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
72777 }
72778 if (isTupleType(t)) {
72779 var restType = getRestTypeOfTupleType(t);
72780 if (restType && ts.isNumericLiteralName(name) && +name >= 0) {
72781 return restType;
72782 }
72783 }
72784 return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
72785 }
72786 return undefined;
72787 }, /*noReductions*/ true);
72788 }
72789 // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of
72790 // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one
72791 // exists. Otherwise, it is the type of the string index signature in T, if one exists.

Calls 14

mapTypeFunction · 0.85
isGenericMappedTypeFunction · 0.85
getBaseConstraintOfTypeFunction · 0.85
getStringLiteralTypeFunction · 0.85
isTypeAssignableToFunction · 0.85
getPropertyOfTypeFunction · 0.85
isCircularMappedPropertyFunction · 0.85
getTypeOfSymbolFunction · 0.85
isTupleTypeFunction · 0.85
getRestTypeOfTupleTypeFunction · 0.85

Tested by

no test coverage detected