Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
docs.forEach(doc => {
if (!(doc instanceof ExportDoc.ExportDoc)) {
return;
}
// Check for Dgeni documents that refer to the same TypeScript symbol. Those can be
// considered as duplicates of the current document.
const similarDocs = docs.filter(d => d.symbol === doc.symbol);
if (similarDocs.length > 1) {
// If there are multiple docs that refer to the same TypeScript symbol, but have a
// different name than the resolved symbol, we can remove those documents, since they
// are just aliasing an already existing export.
similarDocs.filter(d => d.symbol.name !== d.name).forEach(d => duplicates.add(d));
const docsWithSameName = similarDocs.filter(d => d.symbol.name === d.name);
// If there are multiple docs that refer to the same TypeScript symbol and have
// the same name, we need to remove all of those duplicates except one.
if (docsWithSameName.length > 1) {
docsWithSameName.slice(1).forEach(d => duplicates.add(d));
}