benjamn / recast

JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator
MIT License
4.95k stars 346 forks source link

Issue with printing FunctionTypeAnnotation in interface declaration #1332

Open moonyoulove opened 1 year ago

moonyoulove commented 1 year ago

https://github.com/benjamn/recast/blob/0385cd919d045d3e16ba559217efd12d1e2d4222/lib/printer.ts#L1794C32-L1794C32

Somehow, when the first code is parsed into an Abstract Syntax Tree (AST) and then printed, it transforms into the second code snippet, with an additional colon.

declare interface ClockInterface {
  setTime(d: Date): void
}
declare interface ClockInterface {
  setTime: : (d: Date) => void
}