MCPcopy Create free account
hub / github.com/nodejs/node / checkInheritedPropertiesAreIdentical

Function checkInheritedPropertiesAreIdentical

test/fixtures/snapshot/typescript.js:84531–84564  ·  view source on GitHub ↗
(type, typeNode)

Source from the content-addressed store, hash-verified

84529 return ts.arrayFrom(seen.values());
84530 }
84531 function checkInheritedPropertiesAreIdentical(type, typeNode) {
84532 var baseTypes = getBaseTypes(type);
84533 if (baseTypes.length < 2) {
84534 return true;
84535 }
84536 var seen = new ts.Map();
84537 ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) {
84538 seen.set(p.escapedName, { prop: p, containingType: type });
84539 });
84540 var ok = true;
84541 for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
84542 var base = baseTypes_4[_i];
84543 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
84544 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
84545 var prop = properties_6[_a];
84546 var existing = seen.get(prop.escapedName);
84547 if (!existing) {
84548 seen.set(prop.escapedName, { prop: prop, containingType: base });
84549 }
84550 else {
84551 var isInheritedProperty = existing.containingType !== type;
84552 if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
84553 ok = false;
84554 var typeName1 = typeToString(existing.containingType);
84555 var typeName2 = typeToString(base);
84556 var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
84557 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
84558 diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
84559 }
84560 }
84561 }
84562 }
84563 return ok;
84564 }
84565 function checkPropertyInitialization(node) {
84566 if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) {
84567 return;

Callers 1

Calls 11

getBaseTypesFunction · 0.85
resolveDeclaredMembersFunction · 0.85
getPropertiesOfTypeFunction · 0.85
getTypeWithThisArgumentFunction · 0.85
isPropertyIdenticalToFunction · 0.85
typeToStringFunction · 0.85
symbolToStringFunction · 0.85
forEachMethod · 0.65
getMethod · 0.65
addMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected