diff --git a/spec/__snapshots__/integration.test.ts.snap b/spec/__snapshots__/integration.test.ts.snap index 83a95dd..d9c58d9 100644 --- a/spec/__snapshots__/integration.test.ts.snap +++ b/spec/__snapshots__/integration.test.ts.snap @@ -182,7 +182,7 @@ exports[`integration function named export definition should match snapshot 1`] import moduleTwo from 'moduleTwo'; import myDefaultExport, { myNamedExport } from 'moduleThree/deep/file'; import helpers from './local/helpers'; -import { helloNamedFunction } from './namedExportDefinition'; +import { helloNamedFunction, helloAsFunction } from './namedExportDefinition'; jest.mock('moduleOne'); jest.mock('moduleTwo'); @@ -198,6 +198,16 @@ describe('helloNamedFunction', () => { // const retValue = helloNamedFunction(myArgOne,myArgTwo); expect(false).toBeTruthy(); }); +}); +describe('helloAsFunction', () => { + it('should expose a function', () => { + expect(helloAsFunction).toBeDefined(); + }); + + it('helloAsFunction should return expected output', () => { + // const retValue = helloAsFunction(myArgOne,myArgTwo); + expect(false).toBeTruthy(); + }); });" `; diff --git a/spec/fixtures/functions/namedExportDefinition.js b/spec/fixtures/functions/namedExportDefinition.js index d95d764..5173994 100644 --- a/spec/fixtures/functions/namedExportDefinition.js +++ b/spec/fixtures/functions/namedExportDefinition.js @@ -8,4 +8,8 @@ function helloNamedFunction(myArgOne, myArgTwo) { }; -export { helloNamedFunction }; \ No newline at end of file +function helloAsNamedFunction(myArgOne, myArgTwo) { + +}; + +export { helloNamedFunction, helloAsNamedFunction as helloAsFunction }; \ No newline at end of file diff --git a/src/parse-source-file.ts b/src/parse-source-file.ts index 788a83b..1ea279c 100644 --- a/src/parse-source-file.ts +++ b/src/parse-source-file.ts @@ -337,23 +337,24 @@ export function parseSourceFile(file: ts.SourceFile): ParsedSourceFile { function exportDeclarationWalker(node: ts.ExportDeclaration){ debug('exportDeclarationWalker', node.exportClause?.getFullText()); node.exportClause && (node.exportClause as ts.NamedExports).elements.forEach(identifier => { - const idName = identifier.name.escapedText; + const asName = identifier.name.escapedText; + const idName = identifier.propertyName?.escapedText || asName; debug('exportDeclarationWalker', idName); const foundClassByIdentifier = result.classes.find(klass => klass.name === idName); if(foundClassByIdentifier) { - result.exportClass = foundClassByIdentifier; + result.exportClass = { ...foundClassByIdentifier, name: asName }; } const foundFunctionByIdentifier = result.functions.find(func => func.name === idName); if(foundFunctionByIdentifier){ - result.exportFunctions.push(foundFunctionByIdentifier); + result.exportFunctions.push({ ...foundFunctionByIdentifier, name: asName }); } const foundPojoByIdentifier = result.pojos.find(pojo => pojo.name === idName); if(foundPojoByIdentifier){ - result.exportPojos.push(foundPojoByIdentifier); + result.exportPojos.push({ ...foundPojoByIdentifier, name: asName }); } const foundComponentByIdentifier = result.components.find(component => component.name === idName); if(foundComponentByIdentifier){ - result.exportComponents.push(foundComponentByIdentifier); + result.exportComponents.push({ ...foundComponentByIdentifier, name: asName }); } }); }