diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-03-25 05:23:24 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-25 00:23:24 -0400 |
commit | 5ae78eb1de378f04d0b9d54842bcb898053467d6 (patch) | |
tree | 4d0d6a97e6af1f3c3a0a70f1ebe34bdd9d32ac3e /tools/ts_library_builder/build_library.ts | |
parent | 3cc90d9bcf4be58bf88b433ae410f42fa4ad69c7 (diff) |
Update ts_library_builder (#1920)
Diffstat (limited to 'tools/ts_library_builder/build_library.ts')
-rw-r--r-- | tools/ts_library_builder/build_library.ts | 10 |
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>(); |