( checker: ts.TypeChecker, moduleSymbol: ts.Symbol, entrypoint: Entrypoint, pending: Map<string, PendingEntity>, path: ReadonlyArray<string> = [], seenNamespaces: ReadonlySet<ts.Symbol> = new Set() )
| 631 | } |
| 632 | |
| 633 | const collectExports = ( |
| 634 | checker: ts.TypeChecker, |
| 635 | moduleSymbol: ts.Symbol, |
| 636 | entrypoint: Entrypoint, |
| 637 | pending: Map<string, PendingEntity>, |
| 638 | path: ReadonlyArray<string> = [], |
| 639 | seenNamespaces: ReadonlySet<ts.Symbol> = new Set() |
| 640 | ): void => { |
| 641 | for ( |
| 642 | const exported of checker.getExportsOfModule(moduleSymbol).sort((left, right) => |
| 643 | left.name.localeCompare(right.name) |
| 644 | ) |
| 645 | ) { |
| 646 | let symbol = exported |
| 647 | if ((symbol.flags & ts.SymbolFlags.Alias) !== 0) { |
| 648 | symbol = checker.getAliasedSymbol(symbol) |
| 649 | } |
| 650 | const exportPath = [...path, exported.name] |
| 651 | const declarations = symbol.declarations ?? [] |
| 652 | for (const bucket of symbolBuckets(symbol)) { |
| 653 | const selected = bucketDeclarations(symbol, bucket) |
| 654 | if (selected.length === 0) { |
| 655 | continue |
| 656 | } |
| 657 | const key = symbolIdentity(symbol, bucket) |
| 658 | const existing = pending.get(key) |
| 659 | const route = { module: entrypoint.module, path: exportPath } |
| 660 | if (existing === undefined) { |
| 661 | pending.set(key, { |
| 662 | symbol, |
| 663 | bucket, |
| 664 | packageName: entrypoint.packageName, |
| 665 | routes: [route], |
| 666 | declarations: selected |
| 667 | }) |
| 668 | } else if ( |
| 669 | !existing.routes.some((candidate) => |
| 670 | candidate.module === route.module && candidate.path.join(".") === route.path.join(".") |
| 671 | ) |
| 672 | ) { |
| 673 | existing.routes.push(route) |
| 674 | } |
| 675 | } |
| 676 | const isNamespace = (symbol.flags & ts.SymbolFlags.Module) !== 0 |
| 677 | if (isNamespace && !seenNamespaces.has(symbol) && declarations.length > 0) { |
| 678 | collectExports( |
| 679 | checker, |
| 680 | symbol, |
| 681 | entrypoint, |
| 682 | pending, |
| 683 | exportPath, |
| 684 | new Set([...seenNamespaces, symbol]) |
| 685 | ) |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | const canonicalRoute = (routes: ReadonlyArray<ImportRoute>): ImportRoute => |
no test coverage detected