(node: p.TSESTree.FunctionDeclaration, ctx: Context, restFunc: (() => Term) | null)
| 574 | } |
| 575 | |
| 576 | function getRecFunc(node: p.TSESTree.FunctionDeclaration, ctx: Context, restFunc: (() => Term) | null): Term { |
| 577 | if (!node.id) error("function name is required", node); |
| 578 | if (!node.returnType) error("function return type is required", node); |
| 579 | const funcName = node.id.name; |
| 580 | if (node.typeParameters) error("type parameter is not supported for function declaration", node); |
| 581 | const params = node.params.map((param) => { |
| 582 | const { name, type } = getParam(param); |
| 583 | return { name, type: simplifyType(type, ctx) }; |
| 584 | }); |
| 585 | const retType = simplifyType(convertType(node.returnType.typeAnnotation), ctx); |
| 586 | const body = convertStmts(node.body.body, true, ctx); |
| 587 | const rest: Term = restFunc ? restFunc() : { tag: "var", name: funcName, loc: node.loc }; |
| 588 | return { tag: "recFunc", funcName, params, retType, body, rest, loc: node.loc }; |
| 589 | } |
| 590 | |
| 591 | // Convert estree type node to our simplified node definition |
| 592 | function convertType(node: p.TSESTree.TypeNode): Type { |
no test coverage detected