summaryrefslogtreecommitdiff
path: root/tools/ts_library_builder/build_library.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ts_library_builder/build_library.ts')
-rw-r--r--tools/ts_library_builder/build_library.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/ts_library_builder/build_library.ts b/tools/ts_library_builder/build_library.ts
index 0006a8aa4..c2d0ef109 100644
--- a/tools/ts_library_builder/build_library.ts
+++ b/tools/ts_library_builder/build_library.ts
@@ -2,6 +2,7 @@ import { writeFileSync } from "fs";
import { join } from "path";
import * as prettier from "prettier";
import {
+ InterfaceDeclaration,
ExpressionStatement,
NamespaceDeclarationKind,
Project,
@@ -11,6 +12,7 @@ import {
TypeGuards
} from "ts-morph";
import {
+ addInterfaceDeclaration,
addInterfaceProperty,
addSourceComment,
addTypeAlias,
@@ -219,6 +221,7 @@ export function mergeGlobal({
node: ExpressionStatement;
}
>();
+ const globalInterfaces: InterfaceDeclaration[] = [];
// For every augmentation of the global variable in source file, we want
// to extract the type and add it to the global variable map
@@ -243,6 +246,8 @@ export function mergeGlobal({
}
}
}
+ } else if (TypeGuards.isInterfaceDeclaration(node) && node.isExported()) {
+ globalInterfaces.push(node);
}
});
@@ -277,6 +282,11 @@ export function mergeGlobal({
);
}
+ // We need to copy over any interfaces
+ for (const interfaceDeclaration of globalInterfaces) {
+ addInterfaceDeclaration(targetSourceFile, interfaceDeclaration);
+ }
+
// We need to ensure that we only namespace each source file once, so we
// will use this map for tracking that.
const sourceFileMap = new Map<SourceFile, string>();