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

Function propertiesRelatedTo

test/fixtures/snapshot/typescript.js:66441–66583  ·  view source on GitHub ↗
(source, target, reportErrors, excludedProperties, intersectionState)

Source from the content-addressed store, hash-verified

66439 // No array like or unmatched property error - just issue top level error (errorInfo = undefined)
66440 }
66441 function propertiesRelatedTo(source, target, reportErrors, excludedProperties, intersectionState) {
66442 if (relation === identityRelation) {
66443 return propertiesIdenticalTo(source, target, excludedProperties);
66444 }
66445 var result = -1 /* Ternary.True */;
66446 if (isTupleType(target)) {
66447 if (isArrayOrTupleType(source)) {
66448 if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66449 return 0 /* Ternary.False */;
66450 }
66451 var sourceArity = getTypeReferenceArity(source);
66452 var targetArity = getTypeReferenceArity(target);
66453 var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */;
66454 var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */;
66455 var sourceMinLength = isTupleType(source) ? source.target.minLength : 0;
66456 var targetMinLength = target.target.minLength;
66457 if (!sourceRestFlag && sourceArity < targetMinLength) {
66458 if (reportErrors) {
66459 reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength);
66460 }
66461 return 0 /* Ternary.False */;
66462 }
66463 if (!targetRestFlag && targetArity < sourceMinLength) {
66464 if (reportErrors) {
66465 reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity);
66466 }
66467 return 0 /* Ternary.False */;
66468 }
66469 if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) {
66470 if (reportErrors) {
66471 if (sourceMinLength < targetMinLength) {
66472 reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength);
66473 }
66474 else {
66475 reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity);
66476 }
66477 }
66478 return 0 /* Ternary.False */;
66479 }
66480 var sourceTypeArguments = getTypeArguments(source);
66481 var targetTypeArguments = getTypeArguments(target);
66482 var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */));
66483 var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0);
66484 var canExcludeDiscriminants = !!excludedProperties;
66485 for (var i = 0; i < targetArity; i++) {
66486 var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity;
66487 var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */;
66488 var targetFlags = target.target.elementFlags[i];
66489 if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) {
66490 if (reportErrors) {
66491 reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i);
66492 }
66493 return 0 /* Ternary.False */;
66494 }
66495 if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) {
66496 if (reportErrors) {
66497 reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i);
66498 }

Callers 2

structuredTypeRelatedToFunction · 0.85

Calls 15

propertiesIdenticalToFunction · 0.85
isTupleTypeFunction · 0.85
isArrayOrTupleTypeFunction · 0.85
isReadonlyArrayTypeFunction · 0.85
getTypeReferenceArityFunction · 0.85
reportErrorFunction · 0.85
getTypeArgumentsFunction · 0.85
getStartElementCountFunction · 0.85
getEndElementCountFunction · 0.85
removeMissingTypeFunction · 0.85
createArrayTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…