(nodes: p.TSESTree.Statement[])
| 996 | |
| 997 | // Convert estree program nodes to our simplified node definition |
| 998 | function convertProgram(nodes: p.TSESTree.Statement[]): Term { |
| 999 | const globalTypeAliasMap: TypeAliasMap = {}; |
| 1000 | |
| 1001 | const stmts = nodes.filter((node) => { |
| 1002 | switch (node.type) { |
| 1003 | case "ImportDeclaration": |
| 1004 | return false; |
| 1005 | case "TSTypeAliasDeclaration": { |
| 1006 | const name = node.id.name; |
| 1007 | const typeParams = node.typeParameters ? node.typeParameters.params.map((param) => param.name.name) : null; |
| 1008 | const type = convertType(node.typeAnnotation); |
| 1009 | globalTypeAliasMap[name] = { typeParams, type }; |
| 1010 | return false; |
| 1011 | } |
| 1012 | default: |
| 1013 | return true; |
| 1014 | } |
| 1015 | }); |
| 1016 | |
| 1017 | const ctx = { globalTypeAliasMap, typeVarBindings: {} }; |
| 1018 | |
| 1019 | return convertStmts(stmts, false, ctx); |
| 1020 | } |
| 1021 | |
| 1022 | // --- |
| 1023 | // Parse functions |
no test coverage detected