in lib/index.ts [57:72]
export function generateModuleDeclarationFile(nameHint: string, root: any) {
const localName = forceAsIdentifier(nameHint);
const decls = getTopLevelDeclarations(localName, root);
// If we get back just a namespace, we can avoid writing an export=
if (decls.length === 1 && decls[0].kind === 'namespace') {
// Hoist out all the declarations and export them
const members = (decls[0] as dom.NamespaceDeclaration).members;
for (const m of members) m.flags = m.flags! | dom.DeclarationFlags.Export;
return members.map(m => dom.emit(m)).join('');
} else {
// Going to have to write an export=
const result: string[] = decls.map(d => dom.emit(d));
result.unshift(dom.emit(dom.create.exportEquals(localName)));
return result.join('');
}
}