aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r--packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
index b51b17db1..b236c299f 100644
--- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
+++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
@@ -185,6 +185,16 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging:
const referenceNamesWithDuplicates = getAllReferenceNames(propertyName, finalTypeDocOutput, []);
const referenceNames = _.uniq(referenceNamesWithDuplicates);
+ const exportedTypes = getAllTypeNames(finalTypeDocOutput, []);
+ const excessiveReferences = _.difference(exportedTypes, referenceNames);
+ if (!_.isEmpty(excessiveReferences)) {
+ throw new Error(
+ `${packageName} package exports BUT does not need: \n${excessiveReferences.join(
+ '\n',
+ )} \nin it\'s index.ts. Remove them then try again.`,
+ );
+ }
+
const missingReferences: string[] = [];
_.each(referenceNames, referenceName => {
if (!_.includes(allExportedItems, referenceName) && _.isUndefined(EXTERNAL_TYPE_TO_LINK[referenceName])) {
@@ -230,6 +240,27 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging:
});
}
+function getAllTypeNames(node: any, typeNames: string[]): string[] {
+ if (!_.isObject(node)) {
+ return typeNames;
+ }
+ const typeKindStrings = ['Interface', 'Enumeration', 'Type alias'];
+ if (_.includes(typeKindStrings, node.kindString)) {
+ return [...typeNames, node.name];
+ }
+ let updatedTypeNames = typeNames;
+ _.each(node, nodeValue => {
+ if (_.isArray(nodeValue)) {
+ _.each(nodeValue, aNode => {
+ updatedTypeNames = getAllTypeNames(aNode, updatedTypeNames);
+ });
+ } else if (_.isObject(nodeValue)) {
+ updatedTypeNames = getAllTypeNames(nodeValue, updatedTypeNames);
+ }
+ });
+ return updatedTypeNames;
+}
+
function getAllReferenceNames(propertyName: string, node: any, referenceNames: string[]): string[] {
let updatedReferenceNames = referenceNames;
if (!_.isObject(node)) {