import * as babel from '@babel/core' ; import plugin from '../src' ; import recastPlugin from '@flowts/babel-plugin-recast' ; function createTransform ( plugins ) { return function transform ( code ) : string { const result = babel . transformSync ( code . trim ( ) , { babelrc : false , configFile : false , plugins , } ) ; if ( result === null ) { throw new Error ( 'babel.transformSync returned null, probably configuration issue' ) ; } return result . code as string ; } ; } const babelTransform = createTransform ( [ plugin ] ) ; const recastTransform = createTransform ( [ plugin , recastPlugin ] ) ; export function testTransform ( code ) { return { babel : babelTransform ( code ) , recast : recastTransform ( code ) , } ; } const babelTransformDts = createTransform ( [ [ plugin , { isAmbientContext : true } ] , ] ) ; const recastTransformDts = createTransform ( [ [ plugin , { isAmbientContext : true } ] , recastPlugin , ] ) ; export function testTransformDts ( code ) { return { babel : babelTransformDts ( code ) , recast : recastTransformDts ( code ) , } ; }