| 309 | } |
| 310 | |
| 311 | export function FunctionTypeAnnotation( |
| 312 | this: Printer, |
| 313 | node: t.FunctionTypeAnnotation, |
| 314 | parent?: t.Node, |
| 315 | ) { |
| 316 | this.print(node.typeParameters); |
| 317 | this.token("("); |
| 318 | |
| 319 | if (node.this) { |
| 320 | this.word("this"); |
| 321 | this.token(":"); |
| 322 | this.space(); |
| 323 | this.print(node.this.typeAnnotation); |
| 324 | if (node.params.length || node.rest) { |
| 325 | this.token(","); |
| 326 | this.space(); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | this.printList(node.params); |
| 331 | |
| 332 | if (node.rest) { |
| 333 | if (node.params.length) { |
| 334 | this.token(","); |
| 335 | this.space(); |
| 336 | } |
| 337 | this.token("..."); |
| 338 | this.print(node.rest); |
| 339 | } |
| 340 | |
| 341 | this.token(")"); |
| 342 | |
| 343 | // this node type is overloaded, not sure why but it makes it EXTREMELY annoying |
| 344 | |
| 345 | const type = parent?.type; |
| 346 | if ( |
| 347 | type != null && |
| 348 | (type === "ObjectTypeCallProperty" || |
| 349 | type === "ObjectTypeInternalSlot" || |
| 350 | type === "DeclareFunction" || |
| 351 | (type === "ObjectTypeProperty" && parent.method)) |
| 352 | ) { |
| 353 | this.token(":"); |
| 354 | } else { |
| 355 | this.space(); |
| 356 | this.token("=>"); |
| 357 | } |
| 358 | |
| 359 | this.space(); |
| 360 | this.print(node.returnType); |
| 361 | } |
| 362 | |
| 363 | export function FunctionTypeParam(this: Printer, node: t.FunctionTypeParam) { |
| 364 | this.print(node.name); |