* Given an unqualified name, determine whether an existing import is already using this name in * the current scope. * TODO: It would be better to check if *any* symbol uses this name in the current scope.
(importDeclaration: ts.ImportDeclaration[], name: string)
| 309 | * TODO: It would be better to check if *any* symbol uses this name in the current scope. |
| 310 | */ |
| 311 | function importCollisionExists(importDeclaration: ts.ImportDeclaration[], name: string): boolean { |
| 312 | const bindings = importDeclaration.map((declaration) => declaration.importClause?.namedBindings); |
| 313 | const namedBindings: ts.NamedImports[] = bindings.filter( |
| 314 | (binding) => binding !== undefined && ts.isNamedImports(binding), |
| 315 | ) as ts.NamedImports[]; |
| 316 | const specifiers = namedBindings.flatMap((b) => b.elements); |
| 317 | return specifiers.some((s) => s.name.text === name); |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * Generator function that yields an infinite sequence of alternative aliases for a given symbol |
no test coverage detected