(source: ts.SourceFile)
| 198 | /** Collect a per-file map from local binding name → original imported name, |
| 199 | * so `import { X as Y }` resolves Y back to X for the migrated-name check. */ |
| 200 | const collectImportAliases = (source: ts.SourceFile): Map<string, string> => { |
| 201 | const aliases = new Map<string, string>(); |
| 202 | for (const statement of source.statements) { |
| 203 | if (!ts.isImportDeclaration(statement)) continue; |
| 204 | const clause = statement.importClause; |
| 205 | if (!clause || !clause.namedBindings) continue; |
| 206 | if (!ts.isNamedImports(clause.namedBindings)) continue; |
| 207 | for (const spec of clause.namedBindings.elements) { |
| 208 | const localName = spec.name.text; |
| 209 | const importedName = spec.propertyName?.text ?? localName; |
| 210 | aliases.set(localName, importedName); |
| 211 | } |
| 212 | } |
| 213 | return aliases; |
| 214 | }; |
| 215 | |
| 216 | /** Find every `new <ClassName>(...)` call where ClassName (or its import |
| 217 | * origin) is in the migrated set. Rewrites to `<LocalName>.make(...)` so |
no test coverage detected