This is very similar to https://github.com/benjamn/recast/pull/815 but with a test that properly recreates the issue. I ran into the same issue today and needed to use patch-package to fix recast in my project.
It appears that TSTypeAnnotation printer code does not run when you print() a AST with TSTypeAnnotation nodes unless you replace/modify a TSTypeAnnotation and change the typeAnnotation property to be a node of a different type. In my test I switch the typeAnnotation from a TSTypeReference to a TSQualifiedName.
This is very similar to https://github.com/benjamn/recast/pull/815 but with a test that properly recreates the issue. I ran into the same issue today and needed to use
patch-package
to fixrecast
in my project.It appears that
TSTypeAnnotation
printer code does not run when youprint()
a AST withTSTypeAnnotation
nodes unless you replace/modify aTSTypeAnnotation
and change thetypeAnnotation
property to be a node of a different type. In my test I switch thetypeAnnotation
from aTSTypeReference
to aTSQualifiedName
.Thanks!