Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const parseTypescript = path => ensurePropsKey(typescriptParser.parse(path)[0] || {}); // react-docgen-typescript returns array, so
export const mapReactDocgenTypeScript: T.AnalysisMapper = async (
path: string,
ctx: T.AnalysisMapperContext
): Promise => {
try {
const info = reactDocgenTypescript.parse(path);
if (info.length > 0) {
ctx.analysis.attach(path, { type: label, payload: info });
}
// tslint:disable-next-line:no-empty
} catch (err) {}
};
function getDocgen(config, filePath) {
if (filePath.match(/\.tsx$/))
return require('react-docgen-typescript').parse(filePath);
let content = fs.readFileSync(filePath).toString()
if (!config.noSpecialReplacements) {
content = content
.replace('_interopRequireDefault(_react)', 'require("react")')
.replace(/import Component from ["']react-pure-render\/component["']/, 'import {Component} from "react"')
.replace(/export default .*\((\w*)\)+/m, 'export default $1')
}
return docgenParse(content);
}