Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getAstFromCodeString(inputCode: string): babelTypes.Node {
// DO NOT INLINE this variable. It provides stronger typing than recast's type declarations..
const customParser: RecastCustomParser = {
parse: (code) => babelParser.parse(code, {
sourceType: 'module',
plugins: ['typescript', 'classProperties'],
}),
};
return recastParser.parse(inputCode, {parser: customParser});
}