react-tsdoc
Version:
CLI to extract information from React Typescript component files with TSDoc for documentation generation purposes
26 lines (25 loc) • 772 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultExport = void 0;
/**
* Gets the default export (if any) from a file
*
* @param sourceFile - The file to extract the default export from
*/
var getDefaultExport = function (sourceFile) {
var exportedDeclarations = sourceFile.getExportedDeclarations();
var defaultExport = undefined;
exportedDeclarations.forEach(function (exported) {
defaultExport = exported.find(function (node) {
try {
// @ts-ignore
return node.isDefaultExport();
}
catch (_a) {
return false;
}
});
});
return defaultExport;
};
exports.getDefaultExport = getDefaultExport;
;