(nodes: p.TSESTree.Statement[])
| 440 | } |
| 441 | |
| 442 | function convertProgram(nodes: p.TSESTree.Statement[]): Term { |
| 443 | const globalTypeAliasMap: TypeAliasMap = { |
| 444 | "Boolean": { typeParams: null, type: { tag: "Boolean" } }, |
| 445 | "Number": { typeParams: null, type: { tag: "Number" } }, |
| 446 | }; |
| 447 | |
| 448 | const stmts = nodes.filter((node) => { |
| 449 | switch (node.type) { |
| 450 | case "ImportDeclaration": |
| 451 | return false; |
| 452 | case "TSTypeAliasDeclaration": { |
| 453 | const name = node.id.name; |
| 454 | const typeParams = node.typeParameters ? node.typeParameters.params.map((param) => param.name.name) : null; |
| 455 | const type = convertType(node.typeAnnotation); |
| 456 | globalTypeAliasMap[name] = { typeParams, type }; |
| 457 | return false; |
| 458 | } |
| 459 | default: |
| 460 | return true; |
| 461 | } |
| 462 | }); |
| 463 | |
| 464 | const ctx = { globalTypeAliasMap, typeVarBindings: {} }; |
| 465 | |
| 466 | return convertStmts(stmts, false, ctx); |
| 467 | } |
| 468 | |
| 469 | type ExtractTagsSub<T, K> = T extends Type | Term ? ExtractTags<T, K> |
| 470 | : T extends Type[] ? ExtractTags<Type, K>[] |
no test coverage detected