diff --git a/public/api-builder/typescript-package/mocks/readTypeScriptModules/privateModule.ts b/public/api-builder/typescript-package/mocks/readTypeScriptModules/privateModule.ts new file mode 100644 index 0000000000..d4c6ef610a --- /dev/null +++ b/public/api-builder/typescript-package/mocks/readTypeScriptModules/privateModule.ts @@ -0,0 +1 @@ +export var x = 10; \ No newline at end of file diff --git a/public/api-builder/typescript-package/mocks/readTypeScriptModules/publicModule.ts b/public/api-builder/typescript-package/mocks/readTypeScriptModules/publicModule.ts new file mode 100644 index 0000000000..c176de47fe --- /dev/null +++ b/public/api-builder/typescript-package/mocks/readTypeScriptModules/publicModule.ts @@ -0,0 +1 @@ +export { x as y} from './privateModule'; \ No newline at end of file diff --git a/public/api-builder/typescript-package/processors/readTypeScriptModules.js b/public/api-builder/typescript-package/processors/readTypeScriptModules.js index 5597898496..51e56a4242 100644 --- a/public/api-builder/typescript-package/processors/readTypeScriptModules.js +++ b/public/api-builder/typescript-package/processors/readTypeScriptModules.js @@ -223,6 +223,11 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo, if (exportSymbol.flags & ts.SymbolFlags.TypeAlias) { exportDoc.typeDefinition = typeDefinition; } + + // Compute the original module name from the relative file path + exportDoc.originalModule = exportDoc.fileInfo.relativePath + .replace(new RegExp('\.' + exportDoc.fileInfo.extension + '$'), ''); + return exportDoc; } diff --git a/public/api-builder/typescript-package/processors/readTypeScriptModules.spec.js b/public/api-builder/typescript-package/processors/readTypeScriptModules.spec.js index 53d959c70c..76b3605f1c 100644 --- a/public/api-builder/typescript-package/processors/readTypeScriptModules.spec.js +++ b/public/api-builder/typescript-package/processors/readTypeScriptModules.spec.js @@ -13,6 +13,17 @@ describe('readTypeScriptModules', function() { processor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules'); }); + describe('exportDocs', function() { + it('should provide the original module if the export is re-exported', function() { + processor.sourceFiles = [ 'publicModule.ts' ]; + var docs = []; + processor.$process(docs); + + var exportedDoc = docs[1]; + expect(exportedDoc.originalModule).toEqual('privateModule'); + }); + }); + describe('ignoreExportsMatching', function() { it('should ignore exports that match items in the `ignoreExportsMatching` property', function() {